public void StartIncrementalCopy_DefaultDestBlobName() { CloudBlobContainer container = blobUtil.CreateContainer(); CloudBlobContainer destContainer = blobUtil.CreateContainer(); string srcBlobName = Utility.GenNameString("src"); CloudBlob srcBlob = blobUtil.CreateRandomBlob(container, srcBlobName, Microsoft.WindowsAzure.Storage.Blob.BlobType.PageBlob); CloudBlob snapshot1 = srcBlob.Snapshot(); CloudBlob snapshot2 = srcBlob.Snapshot(); CloudBlob snapshot3 = srcBlob.Snapshot(); string destBlobName = srcBlobName; CloudPageBlob destBlob = destContainer.GetPageBlobReference(destBlobName); try { int i = 1; Test.Assert(CommandAgent.StartAzureStorageBlobIncrementalCopy(container.GetPageBlobReference(snapshot1.Name, snapshot1.SnapshotTime), destContainer.Name, null), "copy snapshot1 should success"); Test.Assert(CommandAgent.GetAzureStorageBlobCopyState(destBlob, PowerShellAgent.Context, true), "Get copy status for snapshot1 should success"); int blobCount = destContainer.ListBlobs(destBlobName, true, blobListingDetails: BlobListingDetails.Snapshots).Count(); Test.Assert(blobCount == ++i, string.Format("After IncrementalCopy, blob count: {0} = {1}.", blobCount, i)); Test.Assert(CommandAgent.StartAzureStorageBlobIncrementalCopy(container, srcBlobName, snapshot2.SnapshotTime, destContainer.Name, null), "copy snapshot2 should success"); Test.Assert(CommandAgent.GetAzureStorageBlobCopyState(destBlob, PowerShellAgent.Context, true), "Get copy status for snapshot2 should success"); blobCount = destContainer.ListBlobs(destBlobName, true, blobListingDetails: BlobListingDetails.Snapshots).Count(); Test.Assert(blobCount == ++i, string.Format("After IncrementalCopy, blob count: {0} = {1}.", blobCount, i)); Test.Assert(CommandAgent.StartAzureStorageBlobIncrementalCopy(container.Name, srcBlobName, snapshot3.SnapshotTime, destContainer.Name, null), "copy snapshot3 should success"); Test.Assert(CommandAgent.GetAzureStorageBlobCopyState(destBlob, PowerShellAgent.Context, true), "Get copy status for snapshot3 should success"); blobCount = destContainer.ListBlobs(destBlobName, true, blobListingDetails: BlobListingDetails.Snapshots).Count(); Test.Assert(blobCount == ++i, string.Format("After IncrementalCopy, blob count: {0} = {1}.", blobCount, i)); } finally { blobUtil.RemoveContainer(container); blobUtil.RemoveContainer(destContainer); } }
public void SnapshotBlobInWriting() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); try { CancellationTokenSource cts = new CancellationTokenSource(); Task createTask = blobUtil.CreatePageBlobAsync(container, blobName, cts.Token, true); Test.Assert(CommandAgent.SnapshotAzureStorageBlob(containerName, blobName), Utility.GenComparisonData("Snapshot-AzureStorageBlob", true)); if (lang == Language.NodeJS) { try { string url = (CommandAgent as NodeJSAgent).Output[0]["url"] as string; DateTimeOffset snapshot = new DateTimeOffset((DateTime)(CommandAgent as NodeJSAgent).Output[0]["snapshot"]); CloudBlob snapshotBlob = blobUtil.GetBlobReference(container, blobName, BlobType.PageBlob, snapshot); Test.Assert(snapshotBlob.IsSnapshot, "Expect the the instance is a snapshot"); Test.Assert(snapshotBlob.SnapshotQualifiedUri.ToString() == url, string.Format("Expect the URL to be {0} while get {1}", snapshotBlob.SnapshotQualifiedUri.AbsolutePath, url)); } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } cts.Cancel(); } finally { blobUtil.RemoveContainer(containerName); } }
public void GetFilePipeliningWithGetShareTest() { var directoryName = CloudFileUtil.GenerateUniqueDirectoryName(); var directory = fileUtil.EnsureDirectoryExists(this.fileShare, directoryName); fileUtil.CleanupDirectory(directory); CommandAgent.GetFileShareByName(this.fileShare.Name); ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFile"); ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Path", directoryName); var result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory(directoryName)); CommandAgent.Clear(); var fileName = CloudFileUtil.GenerateUniqueFileName(); var file = fileUtil.CreateFile(this.fileShare.GetRootDirectoryReference(), fileName); CommandAgent.GetFileShareByName(this.fileShare.Name); ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFile"); ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Path", fileName); result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); result.AssertObjectCollection(obj => obj.AssertCloudFile(fileName)); CommandAgent.Clear(); List <CloudFileDirectory> dirs = new List <CloudFileDirectory>(); List <CloudFile> files = new List <CloudFile>(); dirs.Add(directory); files.Add(file); CommandAgent.GetFileShareByName(this.fileShare.Name); ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFile"); result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); result.AssertFileListItems(files, dirs); }
public void RemoveSpecificBlobSnapshot() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); try { CloudBlob blob = blobUtil.CreateRandomBlob(container, blobName); List <CloudBlob> blobs = new List <CloudBlob>(); blob.FetchAttributes(); string snapshotId = string.Empty; int count = random.Next(1, 5); for (int i = 0; i < count; i++) { CloudBlob snapshot = blob.Snapshot(); snapshot.FetchAttributes(); blobs.Add(snapshot); if (string.IsNullOrEmpty(snapshotId)) { snapshotId = snapshot.SnapshotTime.Value.UtcDateTime.ToString("O"); } } blobs.Add(blob); List <IListBlobItem> blobLists = container.ListBlobs(string.Empty, true, BlobListingDetails.All).ToList(); Test.Assert(blobLists.Count == blobs.Count, string.Format("container {0} should contain {1} blobs, and actually it contain {2} blobs", containerName, blobs.Count, blobLists.Count)); Test.Assert(CommandAgent.RemoveAzureStorageBlob(blobName, containerName, snapshotId), Utility.GenComparisonData("Remove-AzureStorageBlob and snapshot", true)); blobLists = container.ListBlobs(string.Empty, true, BlobListingDetails.All).ToList(); Test.Assert(blobLists.Count == blobs.Count - 1, string.Format("container {0} should contain {1} blobs", containerName, blobs.Count - 1)); } finally { blobUtil.RemoveContainer(containerName); } }
public void GetMessageCount() { const int MAX_SIZE = 32; string QUEUE_NAME = Utility.GenNameString("messagecount-"); // create queue if not exists CloudQueue queue = StorageAccount.CreateCloudQueueClient().GetQueueReference(QUEUE_NAME); queue.CreateIfNotExists(); // insert random count queues Random random = new Random(); int count = random.Next(MAX_SIZE) + 1; // count >= 1 for (int i = 1; i <= count; ++i) { queue.AddMessage(new CloudQueueMessage("message " + i)); } // generate comparison data Collection <Dictionary <string, object> > comp = new Collection <Dictionary <string, object> >(); var dic = Utility.GenComparisonData(StorageObjectType.Queue, QUEUE_NAME); dic["ApproximateMessageCount"] = count; comp.Add(dic); try { //--------------Get operation-------------- Test.Assert(CommandAgent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", true)); // Verification for returned values CommandAgent.OutputValidation(comp); } finally { queue.DeleteIfExists(); } }
public void RemoveFileShareWhileAFileIsUploading() { string fileShareName = CloudFileUtil.GenerateUniqueFileShareName(); var fileShare = fileUtil.EnsureFileShareExists(fileShareName); var stream = new BlockReadUntilSetStream(); Task uploadTask = null; try { string fileName = CloudFileUtil.GenerateUniqueFileName(); var file = fileUtil.CreateFile(fileShare, fileName); // Creates a stream which would block the read operation. uploadTask = Task.Factory.StartNew(() => file.UploadFromStream(stream)); CommandAgent.RemoveFileShareByName(fileShareName); var result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); } finally { stream.StopBlockingReadOperation(); if (uploadTask != null) { try { uploadTask.Wait(); } catch { } } stream.Dispose(); fileUtil.DeleteFileShareIfExists(fileShareName); } }
public void NewContainerSas_NotCurrentIP() { blobUtil.SetupTestContainerAndBlob(); try { string containerPermission = "rwdl"; string sastoken = CommandAgent.GetContainerSasFromCmd(blobUtil.Container.Name, string.Empty, containerPermission, null, null, false, null, "1.1.1.1"); try { blobUtil.ValidateBlobWriteableWithSasToken(blobUtil.Blob, sastoken); Test.Error(string.Format("Write blob with should fail since the ipAcl is not current IP.")); } catch (StorageException e) { Test.Info(e.Message); ExpectEqual(e.RequestInformation.HttpStatusCode, 403, "(403) Forbidden"); } } finally { blobUtil.CleanupTestContainerAndBlob(); } }
public void RemoveTableWithoutForce() { string TABLE_NAME = Utility.GenNameString("withoutforce"); // create table if not exists CloudTable table = StorageAccount.CreateCloudTableClient().GetTableReference(TABLE_NAME); table.CreateIfNotExists(); tableUtil.InsertEntityToTable(table); try { //--------------Remove operation-------------- Test.Assert(!CommandAgent.RemoveAzureStorageTable(TABLE_NAME, false), Utility.GenComparisonData("RemoveAzureStorageTable", false)); // Verification for returned values Test.Assert(CommandAgent.Output.Count == 0, "Only 0 row returned : {0}", CommandAgent.Output.Count); Test.Assert(CommandAgent.ErrorMessages[0].Contains("A command that prompts the user failed because"), CommandAgent.ErrorMessages[0]); } finally { // Recover the environment table.DeleteIfExists(); } }
public void SetQuotaWithDiffShareNameTest() { string shareName = Utility.GenNameString(""); CloudFileShare share = fileUtil.EnsureFileShareExists(shareName); try { fileUtil.CleanupDirectory(share.GetRootDirectoryReference()); int quota = random.Next(MinQuota, MaxQuota); Test.Assert(CommandAgent.SetAzureStorageShareQuota(shareName, quota), "Set quota of share with longest name should succeed"); ValidateShareQuota(share, quota); } finally { fileUtil.DeleteFileShareIfExists(shareName); } shareName = Utility.GenNameString("", 3); share = fileUtil.EnsureFileShareExists(shareName); try { fileUtil.CleanupDirectory(share.GetRootDirectoryReference()); int quota = random.Next(MinQuota, MaxQuota); Test.Assert(CommandAgent.SetAzureStorageShareQuota(shareName, quota), "Set quota of share with shortest name should succeed"); ValidateShareQuota(share, quota); } finally { fileUtil.DeleteFileShareIfExists(shareName); } }
public void PipelineMultipleShareNamesTest() { // TODO: Generate more random names for file shares after the // naming rules is settled down. int numberOfShares = this.randomProvider.Next(2, 33); string[] names = Enumerable.Range(0, numberOfShares) .Select(i => CloudFileUtil.GenerateUniqueFileShareName()).ToArray(); var client = StorageAccount.CreateCloudFileClient(); // Ensure all file shares are not exists for (int i = 0; i < names.Length; i++) { while (client.GetShareReference(names[i]).Exists()) { names[i] = CloudFileUtil.GenerateUniqueFileShareName(); } } try { CommandAgent.NewFileShareFromPipeline(); var result = CommandAgent.Invoke(names); CommandAgent.AssertNoError(); result.AssertObjectCollection(obj => result.AssertCloudFileContainer(obj, new List <string>(names)), numberOfShares); } finally { foreach (string fileShareName in names) { fileUtil.DeleteFileShareIfExists(fileShareName); } } }
public void CopyFromSASFile() { CopyFromFile2File((sourceShare) => { string sasToken = sourceShare.GetSharedAccessSignature(new SharedAccessFilePolicy() { Permissions = SharedAccessFilePermissions.Read, SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddHours(1) }); CommandAgent.SetStorageContextWithSASToken(StorageAccount.Credentials.AccountName, sasToken); }, (destShare) => { if (lang == Language.PowerShell) { return(PowerShellAgent.GetStorageContext(StorageAccount.ToString(true))); } else { return(NodeJSAgent.GetStorageContext(StorageAccount.ToString(true))); } }); }
public void LeaseBlobWithInvalidDuration() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); try { CloudBlob blob = blobUtil.CreateRandomBlob(container, blobName); Test.Assert(!CommandAgent.AcquireLease(containerName, blobName, duration: 0), Utility.GenComparisonData("Acquire Lease", false)); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name); Test.Assert(!CommandAgent.AcquireLease(containerName, blobName, duration: 10), Utility.GenComparisonData("Acquire Lease", false)); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name); Test.Assert(!CommandAgent.AcquireLease(containerName, blobName, duration: 100), Utility.GenComparisonData("Acquire Lease", false)); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name); } finally { blobUtil.RemoveContainer(containerName); } }
public void SnapshotLeasedBlob() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); try { CloudBlob blob = blobUtil.CreateRandomBlob(container, blobName); string leaseId = blob.AcquireLease(TimeSpan.FromMinutes(1), string.Empty); Test.Assert(CommandAgent.SnapshotAzureStorageBlob(containerName, blobName, leaseId), Utility.GenComparisonData("Snapshot-AzureStorageBlob", true)); if (lang == Language.NodeJS) { try { string url = (CommandAgent as NodeJSAgent).Output[0]["url"] as string; DateTimeOffset snapshot = new DateTimeOffset((DateTime)(CommandAgent as NodeJSAgent).Output[0]["snapshot"]); CloudBlob snapshotBlob = blobUtil.GetBlobReference(container, blobName, blob.BlobType, snapshot); Test.Assert(snapshotBlob.IsSnapshot, "Expect the the instance is a snapshot"); Test.Assert(snapshotBlob.SnapshotQualifiedUri.ToString() == url, string.Format("Expect the URL to be {0} while get {1}", snapshotBlob.SnapshotQualifiedUri.AbsolutePath, url)); } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } } finally { blobUtil.RemoveContainer(containerName); } }
public void StopCopyWithInvalidNameTest() { string invalidContainerName = "Invalid"; int maxBlobNameLength = 1024; string invalidBlobName = new string('a', maxBlobNameLength + 1); string copyId = "*"; string invalidContainerErrorMessage; string invalidBlobErrorMessage; if (lang == Language.PowerShell) { invalidContainerErrorMessage = String.Format("Container name '{0}' is invalid.", invalidContainerName); invalidBlobErrorMessage = String.Format("Blob name '{0}' is invalid.", invalidBlobName); } else { invalidContainerErrorMessage = "Container name format is incorrect"; invalidBlobErrorMessage = "Value for one of the query parameters specified in the request URI is invalid"; } Test.Assert(!CommandAgent.StopAzureStorageBlobCopy(invalidContainerName, Utility.GenNameString("blob"), copyId, false), "Stop copy should failed with invalid container name"); ExpectedContainErrorMessage(invalidContainerErrorMessage); Test.Assert(!CommandAgent.StopAzureStorageBlobCopy(Utility.GenNameString("container"), invalidBlobName, copyId, false), "Start copy should failed with invalid blob name"); ExpectedContainErrorMessage(invalidBlobErrorMessage); }
public void GetContainerFromValidAndInvalidStorageContext() { PowerShellAgent psAgent = (PowerShellAgent)CommandAgent; CloudStorageAccount account1 = TestBase.GetCloudStorageAccountFromConfig(); string connectionString1 = account1.ToString(true); string randomAccountName = Utility.GenNameString("account"); string randomAccountKey = Utility.GenNameString("key"); randomAccountKey = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(randomAccountKey)); string containerName = Utility.GenNameString("container"); bool savedParamValue = psAgent.UseContextParam; try { CloudBlobContainer container1 = blobUtil.CreateContainer(containerName); string cmd = String.Format("$context1 = new-azurestoragecontext -connectionstring '{0}';$context2 = new-azurestoragecontext -StorageAccountName '{1}' -StorageAccountKey '{2}';($context1, $context2)", connectionString1, randomAccountName, randomAccountKey); psAgent.UseContextParam = false; psAgent.AddPipelineScript(cmd); Test.Assert(!CommandAgent.GetAzureStorageContainer(containerName), Utility.GenComparisonData("Get-AzureStorageContainer using valid and invalid storage contexts", false)); Test.Assert(CommandAgent.ErrorMessages.Count == 1, "invalid storage context should return error"); //the same error may output different error messages in different environments bool expectedError = CommandAgent.ErrorMessages[0].Contains("The remote server returned an error: (502) Bad Gateway") || CommandAgent.ErrorMessages[0].Contains("The remote name could not be resolved") || CommandAgent.ErrorMessages[0].Contains("The operation has timed out"); Test.Assert(expectedError, "use invalid storage account should return 502 or could not be resolved exception or The operation has timed out, actually {0}", CommandAgent.ErrorMessages[0]); } finally { psAgent.UseContextParam = savedParamValue; //TODO test the invalid storage account in subscription blobUtil.RemoveContainer(containerName); } }
public void RemoveBlobByPipeline() { //TODO add more pipeline string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); try { int count = random.Next(1, 5); List <string> blobNames = new List <string>(); for (int i = 0; i < count; i++) { blobNames.Add(Utility.GenNameString("blob")); } List <CloudBlob> blobs = blobUtil.CreateRandomBlob(container, blobNames); string cmd = String.Format("{0} {1}", "Get-AzureStorageContainer", containerName); ((PowerShellAgent)CommandAgent).AddPipelineScript(cmd); cmd = "Get-AzureStorageBlob"; ((PowerShellAgent)CommandAgent).AddPipelineScript(cmd); List <IListBlobItem> blobLists = container.ListBlobs().ToList(); Test.Assert(blobLists.Count == blobs.Count, string.Format("container {0} should contain {1} blobs", containerName, blobs.Count)); Test.Assert(CommandAgent.RemoveAzureStorageBlob(string.Empty, string.Empty), Utility.GenComparisonData("Get-AzureStorageContainer | Get-AzureStorageBlob | Remove-AzureStorageBlob", true)); blobLists = container.ListBlobs().ToList(); Test.Assert(blobLists.Count == 0, string.Format("container {0} should contain {1} blobs", containerName, 0)); } finally { blobUtil.RemoveContainer(containerName); } }
public void GetContainerWithInvalidEndPoint() { PowerShellAgent psAgent = (PowerShellAgent)CommandAgent; bool savedParamValue = psAgent.UseContextParam; try { string accountName = Utility.GenNameString("account"); string accountKey = Utility.GenBase64String("key"); string endPoint = Utility.GenNameString("core.abc.def"); string cmd = String.Format("new-azurestoragecontext -StorageAccountName {0} " + "-StorageAccountKey {1} -Endpoint {2}", accountName, accountKey, endPoint); psAgent.AddPipelineScript(cmd); psAgent.UseContextParam = false; Test.Assert(!CommandAgent.GetAzureStorageContainer(string.Empty), "Get containers with invalid endpoint should fail"); ExpectedContainErrorMessage(ExpectedErrorMsgs); } finally { psAgent.UseContextParam = savedParamValue; } }
public void NewQueueSas_NotCurrentIP() { CloudQueue queue = queueUtil.CreateQueue(); try { string sastoken = CommandAgent.GetQueueSasFromCmd(queue.Name, string.Empty, "raup", null, null, false, null, "2.3.4.5"); try { queueUtil.ValidateQueueReadableWithSasToken(queue, sastoken); Test.Error(string.Format("Queue read hould fail since the ipAcl is not current IP.")); } catch (StorageException e) { Test.Info(e.Message); ExpectEqual(e.RequestInformation.HttpStatusCode, 403, "(403) Forbidden"); } } finally { queueUtil.RemoveQueue(queue); } }
public void ChangeBlobLease() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); string leaseId = string.Empty; string porposedId = Guid.NewGuid().ToString(); try { CloudBlob blob = blobUtil.CreateRandomBlob(container, blobName); Test.Assert(CommandAgent.AcquireLease(containerName, blobName), Utility.GenComparisonData("Acquire blob Lease", true)); if (lang == Language.NodeJS) { try { leaseId = (CommandAgent as NodeJSAgent).Output[0]["id"] as string; Test.Assert(CommandAgent.ChangeLease(containerName, blobName, leaseId, porposedId), Utility.GenComparisonData("Change blob Lease", true)); Test.Assert(!CommandAgent.SnapshotAzureStorageBlob(containerName, blobName, leaseId), Utility.GenComparisonData("Snapshot blob", false)); Test.Assert(CommandAgent.SnapshotAzureStorageBlob(containerName, blobName, porposedId), Utility.GenComparisonData("Snapshot blob", true)); } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } } finally { blobUtil.RemoveContainer(containerName); } }
public void CreateChainsOfDirectoriesWithPathLengthTo1024() { // Create a 250 level depth chains of folder with each directory // named "123". And the first one is named "1234567890123456789012345678" // which is 28 characters long. So the total length would be // 249*(1+3)+28=1024. StringBuilder expectedPathBuilder = new StringBuilder("1234567890123456789012345678"); CommandAgent.NewDirectory(this.fileShare, "1234567890123456789012345678"); for (int i = 1; i < 250; i++) { ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("New-AzureStorageDirectory"); ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Path", "123"); expectedPathBuilder.Append("/123"); } string expectedPath = expectedPathBuilder.ToString(); Test.Assert(expectedPath.Length == 1024, "Generated path should be 1024 while it is {0}.", expectedPath.Length); var result = CommandAgent.Invoke(); CommandAgent.AssertNoError(); result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory(expectedPath)); }
//TODO add test for Get-AzureStorageQueue -Name String.Empty public void GetSpecifiedQueueWithMetaData() { string queueName = Utility.GenNameString("queue"); CloudQueue queue = queueUtil.CreateQueue(queueName); try { //list specified queue with properties and meta data Test.Assert(CommandAgent.GetAzureStorageQueue(queueName), Utility.GenComparisonData("GetAzureStorageQueue", true)); int queueCount = 1; Test.Assert(CommandAgent.Output.Count == queueCount, String.Format("Create {0} queues, but retrieved {1} queues", queueCount, CommandAgent.Output.Count)); // Verification for returned values CommandAgent.OutputValidation(new List <CloudQueue>() { queue }); } finally { queueUtil.RemoveQueue(queueName); } }
public void ChangeWithoutEnoughPermission() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); string containerLeaseId = string.Empty; string blobLeaseId = string.Empty; string proposedId = Guid.NewGuid().ToString(); CloudBlobContainer container = blobUtil.CreateContainer(containerName); try { CloudBlob blob = blobUtil.CreateRandomBlob(container, blobName); Test.Assert(CommandAgent.AcquireLease(containerName, null, duration: 30), Utility.GenComparisonData("Acquire Container Lease", true)); if (lang == Language.NodeJS) { try { containerLeaseId = (CommandAgent as NodeJSAgent).Output[0]["id"] as string; } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } Test.Assert(CommandAgent.AcquireLease(containerName, blobName, duration: 30), Utility.GenComparisonData("Acquire blob Lease", true)); if (lang == Language.NodeJS) { try { blobLeaseId = (CommandAgent as NodeJSAgent).Output[0]["id"] as string; } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } string containerSasToken = string.Empty; string accountSasToken = string.Empty; // Create a container SAS Test.Assert(CommandAgent.NewAzureStorageContainerSAS(containerName, string.Empty, "rl", DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromMinutes(5)), Utility.GenComparisonData("container sas create", true)); if (lang == Language.NodeJS) { containerSasToken = (CommandAgent as NodeJSAgent).Output[0]["sas"] as string; } // Create an account SAS SharedAccessAccountPolicy policy = new SharedAccessAccountPolicy() { Permissions = SharedAccessAccountPermissions.Read, ResourceTypes = SharedAccessAccountResourceTypes.Container, Services = SharedAccessAccountServices.Blob, SharedAccessStartTime = DateTimeOffset.UtcNow, SharedAccessExpiryTime = DateTimeOffset.UtcNow + TimeSpan.FromMinutes(5) }; accountSasToken = Utility.GenerateAccountSAS(policy); CommandAgent.SetStorageContextWithSASToken(StorageAccount.Credentials.AccountName, accountSasToken); Test.Assert(!CommandAgent.ChangeLease(containerName, null, containerLeaseId, proposedId), Utility.GenComparisonData("Change Container Lease", false)); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name); CommandAgent.SetStorageContextWithSASToken(StorageAccount.Credentials.AccountName, containerSasToken); Test.Assert(!CommandAgent.ChangeLease(containerName, blobName, blobLeaseId, proposedId), Utility.GenComparisonData("Change Blob Lease", false)); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name); } finally { blobUtil.RemoveContainer(containerName, containerLeaseId); } }
public void ChangeLeaseBySAS() { string containerName = Utility.GenNameString("container"); string blobName = Utility.GenNameString("blob"); CloudBlobContainer container = blobUtil.CreateContainer(containerName); string containerLease = string.Empty; string porposedId = Guid.NewGuid().ToString(); Random random = new Random(); int duration = random.Next(15, 60); try { string containerSasToken = string.Empty; string accountSasToken = string.Empty; // Create a container SAS Test.Assert(CommandAgent.NewAzureStorageContainerSAS(containerName, string.Empty, "w", DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromMinutes(5)), Utility.GenComparisonData("container sas create", true)); if (lang == Language.NodeJS) { containerSasToken = (CommandAgent as NodeJSAgent).Output[0]["sas"] as string; } // Use an account SAS SharedAccessAccountPolicy policy = new SharedAccessAccountPolicy() { Permissions = SharedAccessAccountPermissions.Write, ResourceTypes = SharedAccessAccountResourceTypes.Container | SharedAccessAccountResourceTypes.Object, Services = SharedAccessAccountServices.Blob, SharedAccessStartTime = DateTimeOffset.UtcNow, SharedAccessExpiryTime = DateTimeOffset.UtcNow + TimeSpan.FromMinutes(5) }; accountSasToken = Utility.GenerateAccountSAS(policy); CommandAgent.SetStorageContextWithSASToken(StorageAccount.Credentials.AccountName, accountSasToken); Test.Assert(CommandAgent.AcquireLease(containerName, null, duration: duration), Utility.GenComparisonData("Acquire Lease", true)); if (lang == Language.NodeJS) { try { containerLease = (CommandAgent as NodeJSAgent).Output[0]["id"] as string; Test.Assert(CommandAgent.ChangeLease(containerName, null, containerLease, porposedId), Utility.GenComparisonData("Change Lease", true)); AccessCondition condition = new AccessCondition() { LeaseId = porposedId }; container.SetMetadata(condition); } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } string blobLease = string.Empty; CloudBlob blob = blobUtil.CreateRandomBlob(container, blobName); blob.Metadata["test1"] = "m1"; blob.Metadata["test2"] = "m2"; // Acquire with account SAS Test.Assert(CommandAgent.AcquireLease(containerName, blobName, duration: duration), Utility.GenComparisonData("Acquire Lease", true)); if (lang == Language.NodeJS) { try { blobLease = (CommandAgent as NodeJSAgent).Output[0]["id"] as string; // Change with container SAS CommandAgent.SetStorageContextWithSASToken(StorageAccount.Credentials.AccountName, containerSasToken); Test.Assert(CommandAgent.ChangeLease(containerName, blobName, blobLease, porposedId), Utility.GenComparisonData("Change Lease", true)); AccessCondition condition = new AccessCondition() { LeaseId = porposedId }; blob.SetMetadata(condition); } catch (Exception e) { Test.Error(string.Format("{0} error: {1}", MethodBase.GetCurrentMethod().Name, e.Message)); } } } finally { blobUtil.RemoveContainer(containerName, porposedId); } }
public void DownloadFileCheckMD5() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); string previousMD5 = FileUtil.GetFileContentMD5(localFilePath); var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); if (sourceFile.Properties.ContentMD5 != previousMD5) { sourceFile.Properties.ContentMD5 = previousMD5; sourceFile.SetProperties(); } var destination = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); // Download file and check its MD5 CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true, CheckMd5: true); var result = CommandAgent.Invoke(); result.AssertNoResult(); string destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(previousMD5, StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", previousMD5, destinationMD5); sourceFile.Properties.ContentMD5 = ""; sourceFile.SetProperties(); // File's ContentMD5 property is empty, download file and check its MD5 CommandAgent.Clear(); CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true, CheckMd5: true); result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidOperationExceptionFullQualifiedErrorId)); destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(previousMD5, StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", previousMD5, destinationMD5); // File's ContentMD5 property is empty, download file without check MD5. CommandAgent.Clear(); CommandAgent.DownloadFile(this.fileShare.Name, cloudFileName, destination, true, CheckMd5: false); result = CommandAgent.Invoke(); result.AssertNoResult(); destinationMD5 = FileUtil.GetFileContentMD5(destination); Test.Assert( destinationMD5.Equals(previousMD5, StringComparison.Ordinal), "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.", previousMD5, destinationMD5); }
public void DownloadFileFromSubDirectoryOfRootTest() { CommandAgent.DownloadFile(this.fileShare, "../a", Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()), true); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidResourceFullQualifiedErrorId)); }
private void CreateDirectoryInternal(string dirName, bool assertForSuccess = true, bool traceCommand = true) { this.CreateDirectoryInternal(() => CommandAgent.NewDirectory(this.fileShare, dirName), dirName, assertForSuccess, traceCommand); }
public void SetPolicyInvalidParameter() { DateTime? startTime = DateTime.Today.AddDays(1); DateTime? expiryTime = DateTime.Today.AddDays(-1); CloudBlobContainer container = blobUtil.CreateContainer(); Utility.ClearStoredAccessPolicy <CloudBlobContainer>(container); try { Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy("$logs", Utility.GenNameString("p", 5), null, null, null), "Set stored acess policy $logs container should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Can not find policy"); } else { ExpectedContainErrorMessage("doesn't exist"); } Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy("CONTAINER", Utility.GenNameString("p", 5), null, null, null), "Set stored acess policy for invalid container name CONTAINER should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("The specifed resource name contains invalid characters."); } else { ExpectedContainErrorMessage("Container name format is incorrect"); } Utility.RawStoredAccessPolicy samplePolicy = Utility.SetUpStoredAccessPolicyData <SharedAccessBlobPolicy>()[0]; CreateStoredAccessPolicy(samplePolicy.PolicyName, samplePolicy.Permission, samplePolicy.StartTime, samplePolicy.ExpiryTime, container); Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, null, startTime, expiryTime), "Set stored access policy for ExpiryTime earlier than StartTime should fail"); ExpectedContainErrorMessage("The expiry time of the specified access policy should be greater than start time"); Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, null, startTime, startTime), "Set stored access policy for ExpiryTime same as StartTime should fail"); ExpectedContainErrorMessage("The expiry time of the specified access policy should be greater than start time"); Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, "x", null, null), "Set stored access policy with invalid permission should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Invalid access permission"); } else { ExpectedContainErrorMessage("Given \"x\" is invalid, supported values are: r, a, c, w, d, l"); } string invalidName = FileNamingGenerator.GenerateValidASCIIOptionValue(65); Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, invalidName, null, null, null), "Create stored access policy with invalid name length should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Can not find policy"); } else { ExpectedContainErrorMessage(string.Format("The policy {0} doesn't exist", invalidName)); } if (lang == Language.PowerShell) { Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, samplePolicy.Permission, samplePolicy.StartTime, null, true, false), "Setting both -StartTime and -NoStartTime should fail"); ExpectedContainErrorMessage("Parameter -StartTime and -NoStartTime are mutually exclusive"); } else { Test.Assert(CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, samplePolicy.Permission, samplePolicy.StartTime, null, true, false), "Setting both -StartTime and -NoStartTime should succeed"); } if (lang == Language.PowerShell) { Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, samplePolicy.Permission, null, samplePolicy.ExpiryTime, false, true), "Setting both -ExpiryTime and -NoExpiryTime should fail"); ExpectedContainErrorMessage("Parameter -ExpiryTime and -NoExpiryTime are mutually exclusive"); } else { Test.Assert(CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, samplePolicy.PolicyName, samplePolicy.Permission, null, samplePolicy.ExpiryTime, false, true), "Setting both -ExpiryTime and -NoExpiryTime should succeed"); } blobUtil.RemoveContainer(container); Test.Assert(!CommandAgent.SetAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", 5), null, null, null), "Set stored access policy against non-existing container should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("does not exist"); } else { ExpectedContainErrorMessage("The specified container does not exist"); } } finally { blobUtil.RemoveContainer(container); } }
public void RemovePolicyInvalid() { CloudBlobContainer container = blobUtil.CreateContainer(); Utility.ClearStoredAccessPolicy <CloudBlobContainer>(container); try { string policyName = "policy"; Test.Assert(!CommandAgent.RemoveAzureStorageContainerStoredAccessPolicy(container.Name, policyName), "Remove non-existing stored access policy should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Can not find policy"); } else { ExpectedContainErrorMessage(string.Format("The policy {0} doesn't exist", policyName)); } string invalidName = FileNamingGenerator.GenerateValidASCIIOptionValue(65); Test.Assert(!CommandAgent.RemoveAzureStorageContainerStoredAccessPolicy(container.Name, invalidName), "Remove stored access policy with name length larger than 64 should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Can not find policy"); } else { ExpectedContainErrorMessage(string.Format("The policy {0} doesn't exist", invalidName)); } Test.Assert(!CommandAgent.RemoveAzureStorageContainerStoredAccessPolicy("CONTAINER", policyName), "Remove stored access policy from invalid container name should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("The specifed resource name contains invalid characters"); } else { ExpectedContainErrorMessage("Container name format is incorrect"); } Test.Assert(!CommandAgent.RemoveAzureStorageContainerStoredAccessPolicy("$logs", policyName), "Remove stored access policy from invalid container name should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Can not find policy"); } else { ExpectedContainErrorMessage(string.Format("The policy {0} doesn't exist", policyName)); } blobUtil.RemoveContainer(container); Test.Assert(!CommandAgent.RemoveAzureStorageContainerStoredAccessPolicy(container.Name, policyName), "Remove stored access policy from invalid container name should fail"); ExpectedContainErrorMessage("The specified container does not exist"); } finally { blobUtil.RemoveContainer(container); } }
public void NewPolicyInvalidParameter() { DateTime? startTime = DateTime.Today.AddDays(1); DateTime? expiryTime = DateTime.Today.AddDays(-1); CloudBlobContainer container = blobUtil.CreateContainer(); Utility.ClearStoredAccessPolicy <CloudBlobContainer>(container); try { Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy("$logs", Utility.GenNameString("p", 5), null, null, null), "Create stored access policy $logs container should fail"); ExpectedContainErrorMessage("The account being accessed does not have sufficient permissions to execute this operation."); Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy("CONTAINER", Utility.GenNameString("p", 5), null, null, null), "Create stored access policy for invalid container name CONTAINER should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("The specifed resource name contains invalid characters."); } else { ExpectedContainErrorMessage("Container name format is incorrect"); } Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", 5), null, startTime, expiryTime), "Create stored access policy for ExpiryTime earlier than StartTime should fail"); ExpectedContainErrorMessage("The expiry time of the specified access policy should be greater than start time"); Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", 5), null, startTime, startTime), "Create stored access policy for ExpiryTime same as StartTime should fail"); ExpectedContainErrorMessage("The expiry time of the specified access policy should be greater than start time"); Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", 5), "x", null, null), "Create stored access policy with invalid permission should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Invalid access permission"); } else { ExpectedContainErrorMessage("Given \"x\" is invalid, supported values are: r, a, c, w, d, l"); } Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, FileNamingGenerator.GenerateValidASCIIOptionValue(65), null, null, null), "Create stored access policy with invalid permission should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Valid names should be 1 through 64 characters long."); } else { ExpectedContainErrorMessage("Reason: Signed identifier ID cannot be empty or over 64 characters in length"); } for (int i = 1; i <= 5; i++) { CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", i), null, null, null); } Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", 6), null, null, null), "Create moret than 5 stored access policies should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("Too many '6' shared access policy identifiers provided"); } else { ExpectedContainErrorMessage("A maximum of 5 access policies may be set"); } blobUtil.RemoveContainer(container); Test.Assert(!CommandAgent.NewAzureStorageContainerStoredAccessPolicy(container.Name, Utility.GenNameString("p", 5), null, null, null), "Create stored access policy against non-existing container should fail"); if (lang == Language.PowerShell) { ExpectedContainErrorMessage("does not exist"); } else { ExpectedContainErrorMessage("The specified container does not exist"); } } finally { blobUtil.RemoveContainer(container); } }
public void GetContainer_withLegalHoldAndImmutabilityPolicy() { if (isResourceMode) { string containerName = Utility.GenNameString("container"); //Creat container Test.Assert((CommandAgent as PowerShellAgent).InvokePSScript( string.Format("Get-AzureRMStorageAccount -ResourceGroupName {0} -Name {1} | New-AzureRmStorageContainer -ContainerName {2}", resourceGroupName, accountName, containerName)), string.Format("Create container for storage account {0} in the resource group {1} should success.", accountName, resourceGroupName)); PSContainer con = GetContainerFromServer(containerName); ValidateContainer(con, resourceGroupName, accountName, containerName, publicaccess: PSPublicAccess.None); //Set ImmutabilityPolicy int immutabilityPeriod = 5; Test.Assert((CommandAgent as PowerShellAgent).InvokePSScript( string.Format("Get-AzureRMStorageAccount -ResourceGroupName {0} -Name {1} | Set-AzureRmStorageContainerImmutabilityPolicy -ContainerName {2} -ImmutabilityPeriod {3}", resourceGroupName, accountName, containerName, immutabilityPeriod)), string.Format("Set Container ImmutabilityPolicy should success.")); Test.Assert(CommandAgent.GetAzureRmStorageContainerImmutabilityPolicy(resourceGroupName, accountName, containerName), "Get Container ImmutabilityPolicy should success."); PSImmutabilityPolicy immuPolicy = GetImmutabilityPolicyFromOutput(); ValidateImmutabilityPolicy(immuPolicy, immutabilityPeriod, "Unlocked"); //Lock ImmutabilityPolicy Test.Assert((CommandAgent as PowerShellAgent).InvokePSScript( string.Format("Get-AzureRmStorageContainer -ResourceGroupName {0} -StorageAccountName {1} -Name {2} | Lock-AzureRmStorageContainerImmutabilityPolicy -Etag '{3}' -Force", resourceGroupName, accountName, containerName, immuPolicy.Etag)), string.Format("Lock Container ImmutabilityPolicy should success.")); Test.Assert(CommandAgent.GetAzureRmStorageContainerImmutabilityPolicy(resourceGroupName, accountName, containerName), "Get Container ImmutabilityPolicy should success."); immuPolicy = GetImmutabilityPolicyFromOutput(); ValidateImmutabilityPolicy(immuPolicy, immutabilityPeriod, "Locked"); //Extend ImmutabilityPolicy int immutabilityPeriod2 = 10; Test.Assert((CommandAgent as PowerShellAgent).InvokePSScript( string.Format("Get-AzureRmStorageContainerImmutabilityPolicy -ResourceGroupName {0} -StorageAccountName {1} -ContainerName {2} | Set-AzureRmStorageContainerImmutabilityPolicy -ImmutabilityPeriod {3} -ExtendPolicy", resourceGroupName, accountName, containerName, immutabilityPeriod2)), string.Format("Extend Container ImmutabilityPolicy should success.")); Test.Assert(CommandAgent.GetAzureRmStorageContainerImmutabilityPolicy(resourceGroupName, accountName, containerName), "Get Container ImmutabilityPolicy should success."); immuPolicy = GetImmutabilityPolicyFromOutput(); ValidateImmutabilityPolicy(immuPolicy, immutabilityPeriod2, "Locked"); //Add Container LegalHold string[] legalhold = new string[] { "legalholdtag1", "legalholdtag2" }; Test.Assert(CommandAgent.AddAzureRmStorageContainerLegalHold(resourceGroupName, accountName, containerName, legalhold), "Add Container LegalHold should success."); PSLegalHold outputLegalhold = GetLegalholdFromOutput(); CompareLegalhold(legalhold, outputLegalhold); //get Container and validate legalhold, ImmutabilityPolicy con = GetContainerFromServer(containerName); ValidateContainer(con, resourceGroupName, accountName, containerName, publicaccess: PSPublicAccess.None); Test.Assert(con.HasImmutabilityPolicy.Value, "Should has HasImmutabilityPolicy = true"); Test.Assert(con.HasLegalHold.Value, "Should has HasLegalHold = true"); Test.AssertEqual(immutabilityPeriod2, con.ImmutabilityPolicy.ImmutabilityPeriodSinceCreationInDays); Test.AssertEqual("Locked", con.ImmutabilityPolicy.State); Test.AssertEqual(3, con.ImmutabilityPolicy.UpdateHistory.Length); Test.AssertEqual("put", con.ImmutabilityPolicy.UpdateHistory[0].Update); Test.AssertEqual(immutabilityPeriod, con.ImmutabilityPolicy.UpdateHistory[0].ImmutabilityPeriodSinceCreationInDays.Value); Test.AssertEqual("lock", con.ImmutabilityPolicy.UpdateHistory[1].Update); Test.AssertEqual(immutabilityPeriod, con.ImmutabilityPolicy.UpdateHistory[1].ImmutabilityPeriodSinceCreationInDays.Value); Test.AssertEqual("extend", con.ImmutabilityPolicy.UpdateHistory[2].Update); Test.AssertEqual(immutabilityPeriod2, con.ImmutabilityPolicy.UpdateHistory[2].ImmutabilityPeriodSinceCreationInDays.Value); Test.AssertEqual(legalhold.Length, con.LegalHold.Tags.Length); if (legalhold.Length == con.LegalHold.Tags.Length) { for (int i = 0; i < legalhold.Length; i++) { Test.AssertEqual(legalhold[i], con.LegalHold.Tags[i].Tag); } } //Remove Legalhold and Container //Test.Assert(CommandAgent.RemoveAzureRmStorageContainerLegalHold(resourceGroupName, accountName, containerName, legalhold), "Remove Container LegalHold should success."); Test.Assert((CommandAgent as PowerShellAgent).InvokePSScript( string.Format("Get-AzureRMStorageAccount -ResourceGroupName {0} -Name {1} | Remove-AzureRmStorageContainerLegalHold -Name {2} -Tag {3}", resourceGroupName, accountName, containerName, legalhold[0] + "," + legalhold[1])), string.Format("Remove Container LegalHold should success.")); //outputLegalhold = GetLegalholdFromOutput(); //CompareLegalhold(null, outputLegalhold); //Test.Assert(CommandAgent.RemoveAzureRmStorageContainer(resourceGroupName, accountName, containerName), "Remove Container should success."); Test.Assert((CommandAgent as PowerShellAgent).InvokePSScript( string.Format("Get-AzureRmStorageContainer -ResourceGroupName {0} -StorageAccountName {1} -Name {2} | Remove-AzureRmStorageContainer -Force", resourceGroupName, accountName, containerName)), string.Format("Remove Container should success.")); } }