public async Task SetClearLegalHold() { // create a blob container string containerName = Recording.GenerateAssetName("testblob"); BlobContainerData data = new BlobContainerData(); BlobContainer container = (await _blobContainerCollection.CreateOrUpdateAsync(containerName, new BlobContainerData())).Value; //set legal hold LegalHold legalHoldModel = new LegalHold(new List <string> { "tag1", "tag2", "tag3" }); LegalHold legalHold = await container.SetLegalHoldAsync(legalHoldModel); //validate Assert.True(legalHold.HasLegalHold); Assert.AreEqual(new List <string> { "tag1", "tag2", "tag3" }, legalHold.Tags); //clear legal hold legalHold = await container.ClearLegalHoldAsync(legalHoldModel); //validate Assert.False(legalHold.HasLegalHold); Assert.AreEqual(0, legalHold.Tags.Count); }
public async Task GetBlobContainer() { string containerName = Recording.GenerateAssetName("testblob"); BlobContainer container = (await _blobContainerCollection.CreateOrUpdateAsync(true, containerName, new BlobContainerData())).Value; Assert.IsEmpty(container.Data.Metadata); Assert.Null(container.Data.PublicAccess); LegalHold legalHoldModel = new LegalHold(new List <string> { "tag1", "tag2", "tag3" }); LegalHold legalHold = await container.SetLegalHoldAsync(legalHoldModel); Assert.IsTrue(legalHold.HasLegalHold); Assert.AreEqual(new List <string> { "tag1", "tag2", "tag3" }, legalHold.Tags); ImmutabilityPolicyData immutabilityPolicyModel = new ImmutabilityPolicyData() { ImmutabilityPeriodSinceCreationInDays = 3 }; ImmutabilityPolicy immutabilityPolicy = (await container.GetImmutabilityPolicy().CreateOrUpdateAsync(true, immutabilityPolicyModel)).Value; Assert.NotNull(immutabilityPolicy.Id); Assert.NotNull(immutabilityPolicy.Data.Type); Assert.NotNull(immutabilityPolicy.Data.Name); Assert.AreEqual(3, immutabilityPolicy.Data.ImmutabilityPeriodSinceCreationInDays); Assert.AreEqual(ImmutabilityPolicyState.Unlocked, immutabilityPolicy.Data.State); immutabilityPolicy = await container.GetImmutabilityPolicy().LockImmutabilityPolicyAsync(immutabilityPolicy.Data.Etag); Assert.NotNull(immutabilityPolicy.Id); Assert.NotNull(immutabilityPolicy.Data.Type); Assert.NotNull(immutabilityPolicy.Data.Name); Assert.AreEqual(3, immutabilityPolicy.Data.ImmutabilityPeriodSinceCreationInDays); Assert.AreEqual(ImmutabilityPolicyState.Locked, immutabilityPolicy.Data.State); immutabilityPolicyModel = new ImmutabilityPolicyData() { ImmutabilityPeriodSinceCreationInDays = 100 }; immutabilityPolicy = await container.GetImmutabilityPolicy().ExtendImmutabilityPolicyAsync(immutabilityPolicy.Data.Etag, parameters: immutabilityPolicyModel); Assert.NotNull(immutabilityPolicy.Id); Assert.NotNull(immutabilityPolicy.Data.Type); Assert.NotNull(immutabilityPolicy.Data.Name); Assert.AreEqual(100, immutabilityPolicy.Data.ImmutabilityPeriodSinceCreationInDays); Assert.AreEqual(ImmutabilityPolicyState.Locked, immutabilityPolicy.Data.State); container = await container.GetAsync(); Assert.IsEmpty(container.Data.Metadata); Assert.AreEqual(PublicAccess.None, container.Data.PublicAccess); Assert.AreEqual(3, container.Data.ImmutabilityPolicy.UpdateHistory.Count); Assert.AreEqual(ImmutabilityPolicyUpdateType.Put, container.Data.ImmutabilityPolicy.UpdateHistory[0].Update); Assert.AreEqual(ImmutabilityPolicyUpdateType.Lock, container.Data.ImmutabilityPolicy.UpdateHistory[1].Update); Assert.AreEqual(ImmutabilityPolicyUpdateType.Extend, container.Data.ImmutabilityPolicy.UpdateHistory[2].Update); Assert.IsTrue(container.Data.LegalHold.HasLegalHold); Assert.AreEqual(3, container.Data.LegalHold.Tags.Count); Assert.AreEqual("tag1", container.Data.LegalHold.Tags[0].Tag); Assert.AreEqual("tag2", container.Data.LegalHold.Tags[1].Tag); Assert.AreEqual("tag3", container.Data.LegalHold.Tags[2].Tag); legalHold = await container.ClearLegalHoldAsync(legalHold); Assert.IsFalse(legalHold.HasLegalHold); await container.DeleteAsync(true); }