示例#1
0
        public async Task SetImmutibilityPolicyAsync_SetLegalHold_BlobSas(BlobSasPermissions sasPermissions)
        {
            // Arrange
            BlobBaseClient blob = await GetNewBlobClient(_containerClient, GetNewBlobName());

            BlobBaseClient sharedKeyBlob = InstrumentClient(
                BlobsClientBuilder.GetServiceClient_OAuthAccount_SharedKey()
                .GetBlobContainerClient(_containerClient.Name)
                .GetBlobBaseClient(blob.Name));
            Uri            blobSasUri    = sharedKeyBlob.GenerateSasUri(sasPermissions, Recording.UtcNow.AddDays(1));
            BlobBaseClient sasBlobClient = InstrumentClient(new BlobBaseClient(blobSasUri, GetOptions()));

            BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy
            {
                ExpiresOn  = Recording.UtcNow.AddMinutes(5),
                PolicyMode = BlobImmutabilityPolicyMode.Unlocked
            };

            // The service rounds Immutability Policy Expiry to the nearest second.
            DateTimeOffset expectedImmutabilityPolicyExpiry = RoundToNearestSecond(immutabilityPolicy.ExpiresOn.Value);

            // Act
            Response <BlobImmutabilityPolicy> response = await sasBlobClient.SetImmutabilityPolicyAsync(
                immutabilityPolicy : immutabilityPolicy);

            // Assert
            Assert.AreEqual(expectedImmutabilityPolicyExpiry, response.Value.ExpiresOn);
            Assert.AreEqual(immutabilityPolicy.PolicyMode, response.Value.PolicyMode);

            // Act
            Response <BlobLegalHoldResult> legalHoldResponse = await sasBlobClient.SetLegalHoldAsync(hasLegalHold : false);

            // Assert
            Assert.IsFalse(legalHoldResponse.Value.HasLegalHold);
        }
示例#2
0
 public void SetUp()
 {
     _containerName   = Recording.GetVariable(nameof(_containerName), _containerName);
     _containerClient = BlobsClientBuilder.GetServiceClient_OAuthAccount_SharedKey().GetBlobContainerClient(_containerName);
 }