Skip to content

Commit 8319b26

Browse files
[smithy-rs] Rollup of 4 commits
Includes commits: 47b4e0e0 Consolidate changelog entries for `once_cell` replacement (#4100) 05d54c35 Run `cargo update` on the runtime lockfiles and the SDK lockfile (#4101) f0c92d92 Revise account-based endpoints integ tests for DDB (#4103) 2164bac5 Update changelog Co-authored-by: AWS SDK Rust Bot <[email protected]> Co-authored-by: AWS SDK Rust Bot <[email protected]> Co-authored-by: ysaito1001 <[email protected]>
1 parent ab9867f commit 8319b26

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

sdk/dynamodb/tests/account-based-endpoints.rs

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ use aws_smithy_runtime::assert_str_contains;
1717
use aws_smithy_runtime_api::http::Response;
1818
use aws_types::endpoint_config::AccountIdEndpointMode;
1919

20-
fn test_client<F>(update_builder: F) -> (Client, CaptureRequestReceiver)
21-
where
22-
F: Fn(Builder) -> Builder,
23-
{
20+
fn test_client(update_builder: fn(Builder) -> Builder) -> (Client, CaptureRequestReceiver) {
2421
let (http_client, request) = capture_request(None);
2522
let builder = Config::builder()
2623
.region(Region::new("us-east-1"))
2724
.credentials_provider(
2825
Credentials::builder()
29-
.account_id("333333333333")
26+
.account_id("123456789012")
3027
.access_key_id("ANOTREAL")
3128
.secret_access_key("notrealrnrELgWzOk3IfjzDKtFBhDby")
3229
.provider_name("test")
@@ -38,6 +35,7 @@ where
3835

3936
async fn call_operation(
4037
client: Client,
38+
table_name: &str,
4139
) -> Result<BatchGetItemOutput, SdkError<BatchGetItemError, Response>> {
4240
let mut attr_v = std::collections::HashMap::new();
4341
attr_v.insert(":s".to_string(), AttributeValue::S("value".into()));
@@ -46,66 +44,68 @@ async fn call_operation(
4644
client
4745
.batch_get_item()
4846
.request_items(
49-
"arn:aws:dynamodb:us-east-1:333333333333:table/table_name",
47+
table_name,
5048
KeysAndAttributes::builder().keys(kv).build().unwrap(),
5149
)
5250
.send()
5351
.await
5452
}
5553

5654
#[tokio::test]
57-
async fn account_id_should_be_included_in_request_uri() {
58-
// With the default `AccountIdEndpointMode::Preferred`
59-
{
60-
let (client, rx) = test_client(std::convert::identity);
61-
let _ = call_operation(client).await;
62-
let req = rx.expect_request();
63-
assert_eq!(
55+
async fn basic_positive_cases() {
56+
let test_cases: &[(fn(Builder) -> Builder, &str, &str)] = &[
57+
(
58+
std::convert::identity,
59+
"arn:aws:dynamodb:us-east-1:333333333333:table/table_name",
6460
"https://333333333333.ddb.us-east-1.amazonaws.com/",
65-
req.uri()
66-
)
67-
}
68-
69-
// With `AccountIdEndpointMode::Required`
70-
{
71-
let (client, rx) =
72-
test_client(|b| b.account_id_endpoint_mode(AccountIdEndpointMode::Required));
73-
let _ = call_operation(client).await;
74-
let req = rx.expect_request();
75-
assert_eq!(
61+
),
62+
(
63+
std::convert::identity,
64+
"table_name", // doesn't specify ARN for the table name
65+
"https://123456789012.ddb.us-east-1.amazonaws.com/", // the account ID should come from credentials
66+
),
67+
(
68+
|b: Builder| b.credentials_provider(Credentials::for_tests()), // credentials do not provide an account ID
69+
"arn:aws:dynamodb:us-east-1:333333333333:table/table_name",
7670
"https://333333333333.ddb.us-east-1.amazonaws.com/",
77-
req.uri()
78-
)
79-
}
80-
}
81-
82-
#[tokio::test]
83-
async fn account_id_should_not_be_included_in_request_uri() {
84-
// If we disable the account-based endpoints, the resulting URI should not include the account ID.
85-
{
86-
let (client, rx) =
87-
test_client(|b| b.account_id_endpoint_mode(AccountIdEndpointMode::Disabled));
88-
let _ = call_operation(client).await;
89-
let req = rx.expect_request();
90-
assert_eq!("https://dynamodb.us-east-1.amazonaws.com/", req.uri());
91-
}
71+
),
72+
(
73+
|b: Builder| b.account_id_endpoint_mode(AccountIdEndpointMode::Preferred), // sets the default mode `Preferred` explicitly
74+
"arn:aws:dynamodb:us-east-1:333333333333:table/table_name",
75+
"https://333333333333.ddb.us-east-1.amazonaws.com/",
76+
),
77+
(
78+
|b: Builder| b.account_id_endpoint_mode(AccountIdEndpointMode::Disabled),
79+
"arn:aws:dynamodb:us-east-1:333333333333:table/table_name",
80+
"https://dynamodb.us-east-1.amazonaws.com/",
81+
),
82+
(
83+
|b: Builder| b.account_id_endpoint_mode(AccountIdEndpointMode::Required),
84+
"arn:aws:dynamodb:us-east-1:333333333333:table/table_name",
85+
"https://333333333333.ddb.us-east-1.amazonaws.com/",
86+
),
87+
];
9288

93-
// If credentials do not include the account ID, neither should the resulting URI.
94-
{
95-
let (client, rx) = test_client(|b| b.credentials_provider(Credentials::for_tests()));
96-
let _ = call_operation(client).await;
89+
for (i, (update_builder, table_name, expected_uri)) in test_cases.into_iter().enumerate() {
90+
let (client, rx) = test_client(*update_builder);
91+
let _ = call_operation(client, table_name).await;
9792
let req = rx.expect_request();
98-
assert_eq!("https://dynamodb.us-east-1.amazonaws.com/", req.uri());
93+
assert_eq!(
94+
*expected_uri,
95+
req.uri(),
96+
"on the {i}th test case where table name is `{table_name}`"
97+
);
9998
}
10099
}
101100

102101
#[tokio::test]
103-
async fn error_should_be_raised_when_account_id_is_expected_but_not_provided() {
102+
async fn error_should_be_raised_when_account_id_is_expected_but_not_resolved() {
104103
let (client, _) = test_client(|b| {
105104
b.account_id_endpoint_mode(AccountIdEndpointMode::Required)
106105
.credentials_provider(Credentials::for_tests())
107106
});
108-
let err = call_operation(client)
107+
// doesn't specify ARN for the table name
108+
let err = call_operation(client, "table_name")
109109
.await
110110
.err()
111111
.expect("request should fail");

versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
smithy_rs_revision = '619c6d6770f2c71795c02cd67ffe4d04da56c190'
1+
smithy_rs_revision = '2164bac592101a54d488c825f386868003072706'
22
aws_doc_sdk_examples_revision = '60dcd5ddc37395a47c7a717bd1966e3a389fc00c'
33

44
[manual_interventions]
@@ -779,7 +779,7 @@ model_hash = '903948a2d14b0c4c29ea9e4be0a93364534d8b7732408dbf2c6ee4cb5b0d8edf'
779779
[crates.aws-sdk-dynamodb]
780780
category = 'AwsSdk'
781781
version = '1.72.0'
782-
source_hash = 'd651cef2e888a80b4434d4e27268fba296689c58d47551c37c10aa9e3a27310b'
782+
source_hash = 'addc280119f15615d395ed515906c3f5909958d40be061d639acbf5a1654d26a'
783783
model_hash = '191ee5f1fa87f1d35dedb4ed308f30b342bbaf70945bc82785aae0c5827f2cef'
784784

785785
[crates.aws-sdk-dynamodbstreams]

0 commit comments

Comments
 (0)