Skip to content

Commit a07c156

Browse files
authored
Added AuthenticationErrorDetail (#42821)
1 parent 88f900e commit a07c156

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

sdk/storage/Azure.Storage.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.Files.Shares_a938f2e083"
5+
"Tag": "net/storage/Azure.Storage.Files.Shares_3a253f1460"
66
}

sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,30 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
368368
await share.DeleteAsync(false);
369369
}
370370

371+
/// <summary>
372+
/// This test exists to ensure AuthenticationErrorDetail is being properly communicated to the customer.
373+
/// </summary>
374+
[RecordedTest]
375+
[ServiceVersion(Min = ShareClientOptions.ServiceVersion.V2024_08_04)]
376+
public async Task CreateAsync_SasError()
377+
{
378+
// Arrange
379+
var shareName = GetNewShareName();
380+
ShareServiceClient service = SharesClientBuilder.GetServiceClient_SharedKey();
381+
Uri sasUri = service.GenerateAccountSasUri(AccountSasPermissions.All, GetUtcNow().AddDays(-1), AccountSasResourceTypes.All);
382+
ShareServiceClient unauthorizedServiceClient = InstrumentClient(new ShareServiceClient(sasUri));
383+
ShareClient share = InstrumentClient(unauthorizedServiceClient.GetShareClient(shareName));
384+
385+
// Act
386+
await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
387+
share.CreateAsync(),
388+
e =>
389+
{
390+
Assert.AreEqual("AuthenticationFailed", e.ErrorCode);
391+
Assert.IsTrue(e.Message.Contains("AuthenticationErrorDetail"));
392+
});
393+
}
394+
371395
[RecordedTest]
372396
public async Task CreateAsync_WithAccountSas()
373397
{

0 commit comments

Comments
 (0)