Skip to content

Commit

Permalink
Fixed Regression where ETags which had quotes surrounding the value, … (
Browse files Browse the repository at this point in the history
  • Loading branch information
amnguye authored Oct 22, 2021
1 parent ec16f62 commit da4593d
Show file tree
Hide file tree
Showing 416 changed files with 55,687 additions and 40,078 deletions.
1 change: 1 addition & 0 deletions sdk/storage/Azure.Storage.Blobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added support for generating SAS URLs with the Permanent Delete ('y') SAS permission.
- Added support for SDK-calculated transactional hash checksums on data transfer.
- Fixed bug where BlobContainerClient.GetBlobs() and .GetBlobsByHierarchyAsync() was not parsing the Object Replication Metadata correctly
- Fixed bug / regression where the ETag values that had quotation marks surrounding it were being removed starting in version 12.9.0.

## 12.10.0 (2021-09-08)
- Includes all features from 12.10.0-beta.1 and 12.10.0-beta.2.
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,9 +2736,9 @@ internal async Task<Stream> OpenReadInternal(
}

// This also makes sure that we fail fast if file doesn't exist.
var blobProperties = await GetPropertiesInternal(conditions: conditions, async, cancellationToken).ConfigureAwait(false);
Response<BlobProperties> blobProperties = await GetPropertiesInternal(conditions: conditions, async, cancellationToken).ConfigureAwait(false);

var etag = blobProperties.Value.ETag;
ETag etag = blobProperties.Value.ETag;
var readConditions = conditions;
if (!allowModifications)
{
Expand Down
80 changes: 40 additions & 40 deletions sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions sdk/storage/Azure.Storage.Blobs/tests/AppendBlobClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ public async Task CreateAsync()

// Assert
Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
IList<BlobItem> blobs = await test.Container.GetBlobsAsync().ToListAsync();
Assert.AreEqual(1, blobs.Count);
Assert.AreEqual(blobName, blobs.First().Name);
Expand Down Expand Up @@ -713,12 +714,18 @@ public async Task AppendBlockAsync()
var data = GetRandomBuffer(blobSize);

// Act
Response<BlobAppendInfo> response;
using (var stream = new MemoryStream(data))
{
await blob.AppendBlockAsync(stream);
response = await blob.AppendBlockAsync(stream);
}

// Assert

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");

// Check if block was appeneded correctly by Downloading the block
Response<BlobDownloadInfo> result = await blob.DownloadAsync(new HttpRange(0, data.Length));
var dataResult = new MemoryStream();
await result.Value.Content.CopyToAsync(dataResult);
Expand Down Expand Up @@ -1125,7 +1132,10 @@ public async Task AppendBlockFromUriAsync_Min()
};

// Act
await destBlob.AppendBlockFromUriAsync(sourceBlob.Uri, options);
Response<BlobAppendInfo> response = await destBlob.AppendBlockFromUriAsync(sourceBlob.Uri, options);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
}
}

Expand Down Expand Up @@ -1684,12 +1694,17 @@ public async Task SealAsync()
await appendBlob.CreateAsync();

// Act
await appendBlob.SealAsync();
Response<BlobInfo> response = await appendBlob.SealAsync();
Response<BlobProperties> propertiesResponse = await appendBlob.GetPropertiesAsync();
Response<BlobDownloadInfo> downloadResponse = await appendBlob.DownloadAsync();
IList<BlobItem> blobs = await test.Container.GetBlobsAsync().ToListAsync();

// Assert

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");

// Ensure the blob is correctly sealed
Assert.IsTrue(propertiesResponse.Value.IsSealed);
Assert.IsTrue(downloadResponse.Value.Details.IsSealed);
Assert.IsTrue(blobs.First().Properties.IsSealed);
Expand Down
55 changes: 43 additions & 12 deletions sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ public async Task DownloadAsync_Streaming()
Response<BlobDownloadStreamingResult> response = await blob.DownloadStreamingAsync();

// Assert

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.Details.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag.ToString()}\"");

Assert.AreEqual(data.Length, response.Value.Details.ContentLength);
var actual = new MemoryStream();
await response.Value.Content.CopyToAsync(actual);
Expand Down Expand Up @@ -3119,7 +3123,8 @@ public async Task SyncCopyFromUriAsync()
await destBlob.GetPropertiesAsync();

// Assert
Assert.IsNotNull(copyResponse.Value.ETag);
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(copyResponse.Value.ETag.ToString(), $"\"{copyResponse.GetRawResponse().Headers.ETag.ToString()}\"");
Assert.IsNotNull(copyResponse.Value.LastModified);
Assert.IsNotNull(copyResponse.Value.CopyId);
Assert.AreEqual(CopyStatus.Success, copyResponse.Value.CopyStatus);
Expand Down Expand Up @@ -4259,6 +4264,8 @@ public async Task GetPropertiesAsync()

// Assert
Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
}

[RecordedTest]
Expand Down Expand Up @@ -4858,7 +4865,7 @@ public async Task SetHttpHeadersAsync()
BlobBaseClient blob = await GetNewBlobClient(test.Container);

// Act
await blob.SetHttpHeadersAsync(new BlobHttpHeaders
Response<BlobInfo> response = await blob.SetHttpHeadersAsync(new BlobHttpHeaders
{
CacheControl = constants.CacheControl,
ContentDisposition = constants.ContentDisposition,
Expand All @@ -4869,13 +4876,18 @@ await blob.SetHttpHeadersAsync(new BlobHttpHeaders
});

// Assert
Response<BlobProperties> response = await blob.GetPropertiesAsync();
Assert.AreEqual(constants.ContentType, response.Value.ContentType);
TestHelper.AssertSequenceEqual(constants.ContentMD5, response.Value.ContentHash);
Assert.AreEqual(constants.ContentEncoding, response.Value.ContentEncoding);
Assert.AreEqual(constants.ContentLanguage, response.Value.ContentLanguage);
Assert.AreEqual(constants.ContentDisposition, response.Value.ContentDisposition);
Assert.AreEqual(constants.CacheControl, response.Value.CacheControl);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");

// Ensure the values has been correctly set by doing a GetProperties call
Response<BlobProperties> propertiesResponse = await blob.GetPropertiesAsync();
Assert.AreEqual(constants.ContentType, propertiesResponse.Value.ContentType);
TestHelper.AssertSequenceEqual(constants.ContentMD5, propertiesResponse.Value.ContentHash);
Assert.AreEqual(constants.ContentEncoding, propertiesResponse.Value.ContentEncoding);
Assert.AreEqual(constants.ContentLanguage, propertiesResponse.Value.ContentLanguage);
Assert.AreEqual(constants.ContentDisposition, propertiesResponse.Value.ContentDisposition);
Assert.AreEqual(constants.CacheControl, propertiesResponse.Value.CacheControl);
}

[RecordedTest]
Expand Down Expand Up @@ -5022,11 +5034,16 @@ public async Task SetMetadataAsync()
IDictionary<string, string> metadata = BuildMetadata();

// Act
await blob.SetMetadataAsync(metadata);
Response<BlobInfo> response = await blob.SetMetadataAsync(metadata);

// Assert
Response<BlobProperties> response = await blob.GetPropertiesAsync();
AssertDictionaryEquality(metadata, response.Value.Metadata);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");

// Ensure the value has been correctly set by doing a GetProperties call
Response<BlobProperties> getPropertiesResponse = await blob.GetPropertiesAsync();
AssertDictionaryEquality(metadata, getPropertiesResponse.Value.Metadata);
}

[RecordedTest]
Expand Down Expand Up @@ -5199,6 +5216,10 @@ public async Task CreateSnapshotAsync()
Response<BlobSnapshotInfo> response = await blob.CreateSnapshotAsync();

// Assert

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");

Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);
}

Expand Down Expand Up @@ -5368,6 +5389,8 @@ public async Task AcquireLeaseAsync()
Response<BlobLease> response = await leaseClient.AcquireAsync(duration);

// Assert
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);
Assert.AreEqual(response.Value.LeaseId, leaseClient.LeaseId);
}
Expand Down Expand Up @@ -5530,6 +5553,9 @@ public async Task RenewLeaseAsync()
// Assert
Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);
Assert.AreEqual(response.Value.LeaseId, lease.LeaseId);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
}

[RecordedTest]
Expand Down Expand Up @@ -5671,6 +5697,8 @@ public async Task ReleaseLeaseAsync()

// Assert
Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
}

[RecordedTest]
Expand Down Expand Up @@ -5976,6 +6004,9 @@ public async Task ChangeLeaseAsync()
Assert.IsNotNull(response.GetRawResponse().Headers.RequestId);
Assert.AreEqual(newLeaseId, response.Value.LeaseId);
Assert.AreEqual(response.Value.LeaseId, lease.LeaseId);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
}

[RecordedTest]
Expand Down
3 changes: 3 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/tests/BlobQuickQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public async Task QueryAsync_Min()

// Assert
Assert.AreEqual("400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n400\n", s);

// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.Details.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag.ToString()}\"");
}

[RecordedTest]
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public async Task<string> SetupBlobMatchCondition(BlobBaseClient blob, string ma
if (match == ReceivedETag)
{
Response<BlobProperties> headers = await blob.GetPropertiesAsync();
return headers.Value.ETag.ToString();
return headers.GetRawResponse().Headers.ETag.ToString();
}
else
{
Expand Down
13 changes: 11 additions & 2 deletions sdk/storage/Azure.Storage.Blobs/tests/BlockBlobClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ public async Task CommitBlockListAsync()
ToBase64(secondBlockName)
};

await blob.CommitBlockListAsync(commitList);
Response<BlobContentInfo> response = await blob.CommitBlockListAsync(commitList);

// Stage 3rd Block
using (var stream = new MemoryStream(data))
Expand All @@ -1100,6 +1100,8 @@ public async Task CommitBlockListAsync()
}

// Assert
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
Response<BlockList> blobList = await blob.GetBlockListAsync(BlockListTypes.All);
Assert.AreEqual(2, blobList.Value.CommittedBlocks.Count());
Assert.AreEqual(ToBase64(firstBlockName), blobList.Value.CommittedBlocks.First().Name);
Expand Down Expand Up @@ -1718,6 +1720,8 @@ public async Task GetBlockListAsync()
Response<BlockList> response = await blob.GetBlockListAsync();

// Assert
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
Assert.AreEqual(1, response.Value.CommittedBlocks.Count());
Assert.AreEqual(blockId0, response.Value.CommittedBlocks.First().Name);
Assert.AreEqual(1, response.Value.UncommittedBlocks.Count());
Expand Down Expand Up @@ -1967,13 +1971,16 @@ public async Task UploadAsync()
var data = GetRandomBuffer(Size);

// Act
Response<BlobContentInfo> response;
using (var stream = new MemoryStream(data))
{
await blob.UploadAsync(
response = await blob.UploadAsync(
content: stream);
}

// Assert
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\"");
IList<BlobItem> blobs = await test.Container.GetBlobsAsync().ToListAsync();
Assert.AreEqual(1, blobs.Count);
Assert.AreEqual(blockBlobName, blobs.First().Name);
Expand Down Expand Up @@ -3132,6 +3139,8 @@ public async Task SyncUploadFromUriAsync()

// Assert
Assert.AreNotEqual(default(ETag), uploadResponse.Value.ETag);
// Ensure that we grab the whole ETag value from the service without removing the quotes
Assert.AreEqual(uploadResponse.Value.ETag.ToString(), $"\"{uploadResponse.GetRawResponse().Headers.ETag.ToString()}\"");
Assert.AreNotEqual(DateTimeOffset.MinValue, uploadResponse.Value.LastModified);

// Validate source and destination blob content matches
Expand Down
Loading

0 comments on commit da4593d

Please sign in to comment.