-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow <Error> to trigger error handling for S3 (#2958)
## Motivation and Context - awslabs/aws-sdk-rust#873 ## Description Add a customization for S3 so that if `<Error>` is the root element, we trigger the error parsing flow ## Testing - Added an integration test ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
Showing
5 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_credential_types::provider::SharedCredentialsProvider; | ||
use aws_credential_types::Credentials; | ||
use aws_sdk_s3::Client; | ||
use aws_smithy_client::test_connection::infallible_connection_fn; | ||
use aws_smithy_http::body::SdkBody; | ||
use aws_smithy_types::error::metadata::ProvideErrorMetadata; | ||
use aws_types::region::Region; | ||
use aws_types::SdkConfig; | ||
|
||
const ERROR_RESPONSE: &str = r#"<?xml version="1.0" encoding="UTF-8"?> | ||
<Error> | ||
<Code>SlowDown</Code> | ||
<Message>Please reduce your request rate.</Message> | ||
<RequestId>K2H6N7ZGQT6WHCEG</RequestId> | ||
<HostId>WWoZlnK4pTjKCYn6eNV7GgOurabfqLkjbSyqTvDMGBaI9uwzyNhSaDhOCPs8paFGye7S6b/AB3A=</HostId> | ||
</Error> | ||
"#; | ||
|
||
#[tokio::test] | ||
async fn status_200_errors() { | ||
let conn = infallible_connection_fn(|_req| http::Response::new(SdkBody::from(ERROR_RESPONSE))); | ||
let sdk_config = SdkConfig::builder() | ||
.credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) | ||
.region(Region::new("us-west-4")) | ||
.http_connector(conn) | ||
.build(); | ||
let client = Client::new(&sdk_config); | ||
let error = client | ||
.delete_objects() | ||
.bucket("bucket") | ||
.send() | ||
.await | ||
.expect_err("should fail"); | ||
assert_eq!(error.into_service_error().code(), Some("SlowDown")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters