Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STG94 Authorization Error Detail #39655

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-share/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/storage/azure-storage-file-share",
"Tag": "java/storage/azure-storage-file-share_011cc52a61"
"Tag": "java/storage/azure-storage-file-share_5a1b3f763c"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public final class StorageError {
@JsonProperty(value = "Message")
private String message;

/*
* The AuthenticationErrorDetail property.
*/
@JsonProperty(value = "AuthenticationErrorDetail")
private String authenticationErrorDetail;

/** Creates an instance of StorageError class. */
public StorageError() {}

Expand All @@ -40,4 +46,24 @@ public StorageError setMessage(String message) {
this.message = message;
return this;
}

/**
* Get the authenticationErrorDetail property: The AuthenticationErrorDetail property.
*
* @return the authenticationErrorDetail value.
*/
public String getAuthenticationErrorDetail() {
return this.authenticationErrorDetail;
}

/**
* Set the authenticationErrorDetail property: The AuthenticationErrorDetail property.
*
* @param authenticationErrorDetail the authenticationErrorDetail value to set.
* @return the StorageError object itself.
*/
public StorageError setAuthenticationErrorDetail(String authenticationErrorDetail) {
this.authenticationErrorDetail = authenticationErrorDetail;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ public void createShare() {
201);
}

@RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-08-04")
@Test
public void createShareSasError() {
ShareServiceClient unauthorizedServiceClient = fileServiceBuilderHelper()
.sasToken("sig=dummyToken")
.buildClient();

ShareClient share = unauthorizedServiceClient.getShareClient(generateShareName());

ShareStorageException e = assertThrows(ShareStorageException.class, share::create);
assertEquals(ShareErrorCode.AUTHENTICATION_FAILED, e.getErrorCode());
assertTrue(e.getServiceMessage().contains("AuthenticationErrorDetail"));
}

@RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2019-12-12")
@ParameterizedTest
@MethodSource("createShareWithArgsSupplier")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.http.rest.Response;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.test.shared.extensions.PlaybackOnly;
import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion;
import com.azure.storage.file.share.implementation.util.ModelHelper;
import com.azure.storage.file.share.models.NtfsFileAttributes;
import com.azure.storage.file.share.models.ShareAudience;
Expand Down Expand Up @@ -88,6 +89,23 @@ public void createShare() {
.assertNext(it -> FileShareTestHelper.assertResponseStatusCode(it, 201)).verifyComplete();
}

@RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-08-04")
@Test
public void createShareSasError() {
ShareServiceAsyncClient unauthorizedServiceClient = fileServiceBuilderHelper()
.sasToken("sig=dummyToken")
.buildAsyncClient();

ShareAsyncClient share = unauthorizedServiceClient.getShareAsyncClient(generateShareName());

StepVerifier.create(share.create())
.verifyErrorSatisfies(r -> {
ShareStorageException e = assertInstanceOf(ShareStorageException.class, r);
assertEquals(ShareErrorCode.AUTHENTICATION_FAILED, e.getErrorCode());
assertTrue(e.getServiceMessage().contains("AuthenticationErrorDetail"));
});
}

@ParameterizedTest
@MethodSource("createShareWithArgsSupplier")
public void createShareWithArgs(Map<String, String> metadata, Integer quota) {
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-share/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ autorest
### Code generation settings
``` yaml
use: '@autorest/java@4.1.16'
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/3f9cca0301ffbb8856826d196c567d821ae190d7/specification/storage/data-plane/Microsoft.FileStorage/preview/2024-05-04/file.json
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/12e0ceead6d4611abdd617d2bbc5c9068e4c772a/specification/storage/data-plane/Microsoft.FileStorage/stable/2024-08-04/file.json
java: true
output-folder: ../
namespace: com.azure.storage.file.share
Expand Down