-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Customizable Operations (#1647)
feature: customizable operations update: CHANGELOG.next.toml update: RFC0017 update: add IntelliJ idea folder to .gitignore add: GenericsGenerator with tests and docs add: rustTypeParameters helper fn with tests and docs add: RetryPolicy optional arg to FluentClientGenerator move: FluentClientGenerator into its own file
- Loading branch information
Showing
18 changed files
with
1,325 additions
and
432 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,6 @@ gradle-app.setting | |
|
||
# Rust build artifacts | ||
target/ | ||
|
||
# IDEs | ||
.idea/ |
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
75 changes: 75 additions & 0 deletions
75
aws/sdk/integration-tests/s3/tests/customizable-operation.rs
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,75 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_http::user_agent::AwsUserAgent; | ||
use aws_sdk_s3::{Credentials, Region}; | ||
use aws_smithy_async::rt::sleep::TokioSleep; | ||
use aws_smithy_client::test_connection::capture_request; | ||
|
||
use std::convert::Infallible; | ||
use std::sync::Arc; | ||
use std::time::{Duration, UNIX_EPOCH}; | ||
|
||
#[tokio::test] | ||
async fn test_s3_ops_are_customizable() -> Result<(), aws_sdk_s3::Error> { | ||
let creds = Credentials::new( | ||
"ANOTREAL", | ||
"notrealrnrELgWzOk3IfjzDKtFBhDby", | ||
Some("notarealsessiontoken".to_string()), | ||
None, | ||
"test", | ||
); | ||
let conf = aws_sdk_s3::Config::builder() | ||
.credentials_provider(creds) | ||
.region(Region::new("us-east-1")) | ||
.sleep_impl(Arc::new(TokioSleep::new())) | ||
.build(); | ||
let (conn, rcvr) = capture_request(None); | ||
|
||
let client = aws_sdk_s3::Client::from_conf_conn(conf, conn); | ||
|
||
let op = client | ||
.list_buckets() | ||
.customize() | ||
.await | ||
.expect("list_buckets is customizable") | ||
.map_operation(|mut op| { | ||
op.properties_mut() | ||
.insert(UNIX_EPOCH + Duration::from_secs(1624036048)); | ||
op.properties_mut().insert(AwsUserAgent::for_tests()); | ||
|
||
Result::<_, Infallible>::Ok(op) | ||
}) | ||
.expect("inserting into the property bag is infallible"); | ||
|
||
// The response from the fake connection won't return the expected XML but we don't care about | ||
// that error in this test | ||
let _ = op | ||
.send() | ||
.await | ||
.expect_err("this will fail due to not receiving a proper XML response."); | ||
|
||
let expected_req = rcvr.expect_request(); | ||
let auth_header = expected_req | ||
.headers() | ||
.get("Authorization") | ||
.unwrap() | ||
.to_owned(); | ||
|
||
// This is a snapshot test taken from a known working test result | ||
let snapshot_signature = | ||
"Signature=c2028dc806248952fc533ab4b1d9f1bafcdc9b3380ed00482f9935541ae11671"; | ||
assert!( | ||
auth_header | ||
.to_str() | ||
.unwrap() | ||
.contains(snapshot_signature), | ||
"authorization header signature did not match expected signature: got {}, expected it to contain {}", | ||
auth_header.to_str().unwrap(), | ||
snapshot_signature | ||
); | ||
|
||
Ok(()) | ||
} |
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
Oops, something went wrong.