Skip to content

Commit

Permalink
AWS Integration tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Oct 11, 2023
1 parent 527aa8d commit 60b6a52
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 19 deletions.
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-config/src/sts/assume_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mod test {
let req = request.expect_request();
let str_body = std::str::from_utf8(req.body().bytes().unwrap()).unwrap();
assert!(str_body.contains("1234567"), "{}", str_body);
assert_eq!(req.uri(), "https://sts.us-east-1.amazonaws.com");
assert_eq!(req.uri(), "https://sts.us-east-1.amazonaws.com/");
}

#[tokio::test]
Expand Down Expand Up @@ -411,7 +411,7 @@ mod test {
.await;
let _ = dbg!(provider.provide_credentials().await);
let req = request.expect_request();
assert_eq!(req.uri(), "https://sts.us-west-2.amazonaws.com");
assert_eq!(req.uri(), "https://sts.us-west-2.amazonaws.com/");
}

/// Test that `build()` where no provider is passed still works
Expand Down
3 changes: 2 additions & 1 deletion aws/sdk/integration-tests/dynamodb/tests/movies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use dynamodb::types::{
ScalarAttributeType, TableStatus,
};
use dynamodb::Client;
use http::header::AUTHORIZATION;
use http::Uri;
use serde_json::Value;
use std::collections::HashMap;
Expand Down Expand Up @@ -186,7 +187,7 @@ async fn movies_it() {
]
);

http_client.assert_requests_match(&["AUTHORIZATION", "x-amz-date"]);
http_client.assert_requests_match(&[AUTHORIZATION.as_str(), "x-amz-date"]);
}

/// Test connection for the movies IT
Expand Down
3 changes: 2 additions & 1 deletion aws/sdk/integration-tests/kms/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use aws_sdk_kms::operation::RequestId;
use aws_smithy_http::body::SdkBody;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
use http::header::AUTHORIZATION;
use http::Uri;
use kms::config::{Config, Credentials, Region};

Expand Down Expand Up @@ -165,5 +166,5 @@ async fn generate_random_keystore_not_found() {
inner.request_id(),
Some("bfe81a0a-9a08-4e71-9910-cdb5ab6ea3b6")
);
http_client.assert_requests_match(&["AUTHORIZATION"]);
http_client.assert_requests_match(&[AUTHORIZATION.as_str()]);
}
2 changes: 2 additions & 0 deletions aws/sdk/integration-tests/qldbsession/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_sdk_qldbsession::config::{Config, Credentials, Region};
use aws_sdk_qldbsession::types::StartSessionRequest;
use aws_sdk_qldbsession::Client;
Expand Down
2 changes: 2 additions & 0 deletions aws/sdk/integration-tests/s3/tests/checksums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_config::SdkConfig;
use aws_credential_types::provider::SharedCredentialsProvider;
use aws_sdk_s3::config::{Credentials, Region};
Expand Down
20 changes: 12 additions & 8 deletions aws/sdk/integration-tests/s3/tests/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_credential_types::provider::SharedCredentialsProvider;
use aws_sdk_s3::config::Builder;
use aws_sdk_s3::config::{Credentials, Region};
Expand Down Expand Up @@ -136,14 +138,16 @@ async fn s3_object_lambda_no_cross_region() {
#[tokio::test]
async fn write_get_object_response() {
let (req, client) = test_client(|b| b);
let _write = client
.write_get_object_response()
.request_route("req-route")
.request_token("token")
.status_code(200)
.body(vec![1, 2, 3].into())
.send()
.await;
let _write = dbg!(
client
.write_get_object_response()
.request_route("req-route")
.request_token("token")
.status_code(200)
.body(vec![1, 2, 3].into())
.send()
.await
);

let captured_request = req.expect_request();
assert_eq!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_credential_types::provider::SharedCredentialsProvider;
use aws_sdk_s3::Config;
use aws_sdk_s3::{config::Credentials, config::Region, types::ObjectAttributes, Client};
Expand Down
2 changes: 2 additions & 0 deletions aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_credential_types::provider::SharedCredentialsProvider;
use aws_sdk_s3::Config;
use aws_sdk_s3::{config::Credentials, config::Region, primitives::ByteStream, Client};
Expand Down
4 changes: 2 additions & 2 deletions aws/sdk/integration-tests/s3/tests/presigning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn test_presigning_with_payload_headers() {
.put_object()
.bucket("test-bucket")
.key("test-key")
.content_length(123456)
.content_length(12345)
.content_type("application/x-test")
})
.await;
Expand Down Expand Up @@ -145,7 +145,7 @@ async fn test_presigning_with_payload_headers() {
presigned.headers().get(CONTENT_TYPE),
Some("application/x-test")
);
assert_eq!(presigned.headers().get(CONTENT_LENGTH), Some("123456"));
assert_eq!(presigned.headers().get(CONTENT_LENGTH), Some("12345"));
assert_eq!(presigned.headers().iter().count(), 2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_credential_types::provider::SharedCredentialsProvider;
use aws_sdk_s3::config::{Credentials, Region};
use aws_sdk_s3::{Client, Config};
Expand Down
2 changes: 2 additions & 0 deletions aws/sdk/integration-tests/s3/tests/signing-it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]

use aws_credential_types::provider::SharedCredentialsProvider;
use aws_sdk_s3::config::{Credentials, Region};
use aws_sdk_s3::{Client, Config};
Expand Down
4 changes: 4 additions & 0 deletions aws/sdk/integration-tests/s3control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ http = "0.2.0"
serde_json = "1.0.0"
tokio = { version = "1.23.1", features = ["full", "test-util"] }
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }

[[test]]
name = "signing-it"
required-features = ["test-util"]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_types::config_bag::{ConfigBag, Storable, StoreReplace};
use aws_smithy_types::endpoint::Endpoint;
use http::header::HeaderName;
use http::HeaderValue;
use http::uri::PathAndQuery;
use http::{HeaderValue, Uri};
use std::borrow::Cow;
use std::fmt::Debug;
use std::str::FromStr;
use tracing::trace;
Expand Down Expand Up @@ -141,10 +143,23 @@ fn apply_endpoint(
endpoint: &Endpoint,
endpoint_prefix: Option<&EndpointPrefix>,
) -> Result<(), BoxError> {
let prefix = endpoint_prefix
.map(EndpointPrefix::as_str)
.unwrap_or_default();
let endpoint_url = format!("{}{}", prefix, endpoint.url());
let endpoint_url = match endpoint_prefix {
None => Cow::Borrowed(endpoint.url()),
Some(prefix) => {
let parsed = endpoint.url().parse::<Uri>()?;
let scheme = parsed.scheme_str().unwrap_or_default();
let prefix = prefix.as_str();
let authority = parsed
.authority()
.map(|auth| auth.as_str())
.unwrap_or_default();
let path_and_query = parsed
.path_and_query()
.map(PathAndQuery::as_str)
.unwrap_or_default();
Cow::Owned(format!("{scheme}://{prefix}{authority}{path_and_query}"))
}
};

request
.uri_mut()
Expand Down Expand Up @@ -174,3 +189,23 @@ fn apply_endpoint(
}
Ok(())
}

#[cfg(test)]
mod test {
use aws_smithy_http::endpoint::EndpointPrefix;
use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_types::endpoint::Endpoint;

#[test]
fn test_apply_endpoint() {
let mut req = HttpRequest::empty();
req.set_uri("/foo?bar=1").unwrap();
let endpoint = Endpoint::builder().url("https://s3.amazon.com").build();
let prefix = EndpointPrefix::new("prefix.subdomain.").unwrap();
super::apply_endpoint(&mut req, &endpoint, Some(&prefix)).expect("should succeed");
assert_eq!(
req.uri(),
"https://prefix.subdomain.s3.amazon.com/foo?bar=1"
);
}
}

0 comments on commit 60b6a52

Please sign in to comment.