/** * Deletes the share if it exists. * * @return <code>true</code> if the share existed and was deleted; otherwise, <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean deleteIfExists() throws StorageException { return this.deleteIfExists(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Deletes the share if it exists. * * @return <code>true</code> if the share existed and was deleted; otherwise, <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean deleteIfExists() throws StorageException { return this.deleteIfExists(DeleteShareSnapshotsOption.NONE, null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Deletes the share if it exists using the specified request options and operation context. * * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the share. * @param options * A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying * <code>null</code> will use the default request options from the associated service client ( * {@link CloudFileClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * * @return <code>true</code> if the share existed and was deleted; otherwise, <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException { return this.deleteIfExists(DeleteShareSnapshotsOption.NONE, accessCondition, options, opContext); }
/** * Deletes the share if it exists using the specified request options and operation context. * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the share. * @param options * A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying * <code>null</code> will use the default request options from the associated service client ( * {@link CloudFileClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * * @return <code>true</code> if the share existed and was deleted; otherwise, <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException { return this.deleteIfExists(DeleteShareSnapshotsOption.NONE, accessCondition, options, opContext); }
@After public void fileSASTestMethodTearDown() throws StorageException { this.share.deleteIfExists(); }
@After public void cloudFileDirectoryTearDown() throws StorageException { this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null); }
@After public void fileShareTestMethodTearDown() throws StorageException { this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null); }
@After public void fileEncryptionTestMethodTearDown() throws StorageException { this.share.deleteIfExists(); }
@After public void fileTestMethodTearDown() throws StorageException { this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null); }
/** * DeleteIfExists test. * * @throws StorageException */ @Test public void testCloudFileShareDeleteIfExists() throws StorageException { assertFalse(this.share.deleteIfExists()); this.share.create(); assertTrue(this.share.deleteIfExists()); assertFalse(this.share.exists()); assertFalse(this.share.deleteIfExists()); }
@After public void accountSasTestMethodTearDown() throws StorageException, URISyntaxException { this.blobContainer.deleteIfExists(); this.fileShare.deleteIfExists(); this.queueQueue.deleteIfExists(); this.tableTable.deleteIfExists(); }
@Test @Category({ SlowTests.class }) public void testShareSASCombinations() throws StorageException, URISyntaxException, IOException, InvalidKeyException, InterruptedException { EnumSet<SharedAccessFilePermissions> permissionSet = null; Map<Integer, CloudFileShare> shares = new HashMap<Integer, CloudFileShare>(); try { for (int bits = 0x1; bits < 0x40; bits++) { shares.put(bits, FileTestHelper.getRandomShareReference()); shares.get(bits).createIfNotExists(); permissionSet = getPermissions(bits); FileSharePermissions perms = new FileSharePermissions(); perms.getSharedAccessPolicies().put("readwrite" + bits, createSharedAccessPolicy(permissionSet, 300)); shares.get(bits).uploadPermissions(perms); } Thread.sleep(30000); for (int bits = 0x1; bits < 0x20; bits++) { permissionSet = getPermissions(bits); String sasToken = shares.get(bits).generateSharedAccessSignature(null, "readwrite" + bits); CloudFile testFile = FileTestHelper.uploadNewFile(shares.get(bits), 64, null); testAccess(sasToken, permissionSet, shares.get(bits), testFile); } } finally { for (int bits = 0x1; bits < shares.size(); bits++) { shares.get(bits).deleteIfExists(); } } }
private void testTableAccountSas(final boolean useHttps, final int bits) throws InvalidKeyException, StorageException, URISyntaxException, IOException { SharedAccessAccountPolicy policy = generatePolicy(bits, SharedAccessAccountService.TABLE, null, null); this.tableTable = this.tableClient.getTableReference("tabletest" + bits); try { testTableAccountSas(this.tableTable, useHttps, policy); } catch (StorageException ex) { if (bits < AccountSasTests.OBJECT_CODE || bits % AccountSasTests.OBJECT_CODE == AccountSasTests.EMPTY_PERMS_CODE) { // Expected failure if permissions or resource type is empty. assertEquals(AccountSasTests.QUERY_PARAM_MISSING_MESSAGE, ex.getMessage()); } else { throw ex; } } finally { this.fileShare.deleteIfExists(); } }
private void testFileAccountSas(final boolean useHttps, final int bits) throws InvalidKeyException, StorageException, URISyntaxException, IOException { SharedAccessAccountPolicy policy = generatePolicy(bits, SharedAccessAccountService.FILE, null, null); this.fileShare = this.fileClient.getShareReference("filetest" + bits); try { testFileAccountSas(this.fileShare, useHttps, policy); } catch (StorageException ex) { if (bits < AccountSasTests.OBJECT_CODE || bits % AccountSasTests.OBJECT_CODE == AccountSasTests.EMPTY_PERMS_CODE) { // Expected failure if permissions or resource type is empty. assertEquals(AccountSasTests.QUERY_PARAM_MISSING_MESSAGE, ex.getMessage()); } else { throw ex; } } finally { this.fileShare.deleteIfExists(); } }
fileClient.getShareReference(shareName).deleteIfExists();
share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
this.fileShare.deleteIfExists();
@Test @Category({ DevFabricTests.class, DevStoreTests.class, CloudTests.class }) public void testFileProtocolAccountSas() throws InvalidKeyException, StorageException, URISyntaxException, IOException { // Ensure attempt from http fails against HTTPS_ONLY try { testFileAccountSas(this.fileShare, false, generatePolicy( AccountSasTests.FULL_PERMS_CODE, SharedAccessAccountService.FILE, null, SharedAccessProtocols.HTTPS_ONLY)); fail(); } catch (IllegalArgumentException ex) { assertEquals(SR.CANNOT_TRANSFORM_NON_HTTPS_URI_WITH_HTTPS_ONLY_CREDENTIALS, ex.getMessage()); } finally { this.fileShare.deleteIfExists(); } // Ensure attempt from https succeeds against HTTPS_ONLY this.fileShare = FileTestHelper.getRandomShareReference(); testFileAccountSas(this.fileShare, true, generatePolicy( AccountSasTests.FULL_PERMS_CODE, SharedAccessAccountService.FILE, null, SharedAccessProtocols.HTTPS_ONLY)); // Ensure attempts from both https and http succeed against HTTPS_HTTP this.fileShare = FileTestHelper.getRandomShareReference(); testFileAccountSas(this.fileShare, true, generatePolicy( AccountSasTests.FULL_PERMS_CODE, SharedAccessAccountService.FILE, null, SharedAccessProtocols.HTTPS_HTTP)); this.fileShare = FileTestHelper.getRandomShareReference(); testFileAccountSas(this.fileShare, false, generatePolicy( AccountSasTests.FULL_PERMS_CODE, SharedAccessAccountService.FILE, null, SharedAccessProtocols.HTTPS_HTTP)); }
assertTrue(this.share.deleteIfExists(null, null, ctx));