Skip to content

Commit 705dd23

Browse files
authored
Fixed bug where blob container get properties throw null exception when access policy was null (Azure#27203)
1 parent b6fab7a commit 705dd23

File tree

5 files changed

+299
-11
lines changed

5 files changed

+299
-11
lines changed

sdk/storage/Azure.Storage.Blobs/CHANGELOG.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22

33
## 12.11.0-beta.4 (Unreleased)
44

5-
### Features Added
65
- Added support for progress reporting with DownloadToAsync().
7-
8-
### Breaking Changes
9-
10-
### Bugs Fixed
116
- Fixed a bug where BlobBaseClient.DownloadTo() would result in an ObjectDisposedException on .NET Framework in certain network conditions.
127
- Added nullable version of `BlobProperties.CopyStatus` called `BlobCopyStatus`, allowing a null value when Storage doesn't return a value.
13-
14-
### Other Changes
8+
- Fixed a bug where BlobContainerClient.GetProperties() would throw an ArgumentNullException when the AccessPolicy was null
159

1610
## 12.11.0-beta.3 (2022-02-07)
1711
- Added support for service version 2021-04-10.

sdk/storage/Azure.Storage.Blobs/src/Models/BlobSignedIdentifier.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ internal BlobSignedIdentifier(string id, BlobAccessPolicy accessPolicy)
1818
{
1919
throw new ArgumentNullException(nameof(id));
2020
}
21-
if (accessPolicy == null)
22-
{
23-
throw new ArgumentNullException(nameof(accessPolicy));
24-
}
2521

2622
Id = id;
2723
AccessPolicy = accessPolicy;

sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,37 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
11361136
e => Assert.AreEqual("LeaseNotPresentWithContainerOperation", e.ErrorCode));
11371137
}
11381138

1139+
[RecordedTest]
1140+
public async Task GetAccessPolicyAsync_EmptyAccessPolicy()
1141+
{
1142+
await using DisposingContainer test = await GetTestContainerAsync();
1143+
1144+
// Arrange
1145+
PublicAccessType publicAccessType = PublicAccessType.BlobContainer;
1146+
BlobSignedIdentifier[] signedIdentifiers = new[]
1147+
{
1148+
new BlobSignedIdentifier
1149+
{
1150+
Id = GetNewString(),
1151+
// Empty Access Policy
1152+
}
1153+
};
1154+
1155+
// Act
1156+
Response<BlobContainerInfo> response = await test.Container.SetAccessPolicyAsync(
1157+
accessType: publicAccessType,
1158+
permissions: signedIdentifiers
1159+
);
1160+
1161+
// Assert
1162+
Response<BlobContainerAccessPolicy> getPolicyResponse = await test.Container.GetAccessPolicyAsync();
1163+
Assert.AreEqual(1, getPolicyResponse.Value.SignedIdentifiers.Count());
1164+
1165+
BlobSignedIdentifier acl = getPolicyResponse.Value.SignedIdentifiers.First();
1166+
Assert.AreEqual(signedIdentifiers[0].Id, acl.Id);
1167+
Assert.IsNull(acl.AccessPolicy);
1168+
}
1169+
11391170
[RecordedTest]
11401171
public async Task GetAccessPolicyAsync_Error()
11411172
{

sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/GetAccessPolicyAsync_EmptyAccessPolicy.json

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/GetAccessPolicyAsync_EmptyAccessPolicyAsync.json

Lines changed: 133 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)