Skip to content

Commit

Permalink
Correct region warning when endpoint url provided (awslabs#535)
Browse files Browse the repository at this point in the history
* Corrected the warn message condition for region detection

Signed-off-by: Ankit Saurabh <[email protected]>

* Added test for documenting endpoint_url argument behaviour

Signed-off-by: Ankit Saurabh <[email protected]>

* Added the assert for signing region to document it

Signed-off-by: Ankit Saurabh <[email protected]>

---------

Signed-off-by: Ankit Saurabh <[email protected]>
  • Loading branch information
Ankit Saurabh authored Sep 26, 2023
1 parent 5383dd7 commit 63e4a74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions mountpoint-s3-client/src/endpoint_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,23 @@ mod test {
assert_eq!("https://example.com/doc-example-bucket", endpoint_uri.as_os_str());
}

#[test]
fn test_endpoint_arg_with_region() {
let endpoint_config = EndpointConfig::new("us-east-1")
.endpoint(Uri::new_from_str(&Allocator::default(), "https://s3.eu-west-1.amazonaws.com").unwrap());
let resolved_endpoint = endpoint_config.resolve_for_bucket("doc-example-bucket").unwrap();
let endpoint_uri = resolved_endpoint.uri().unwrap();
// region is ignored when endpoint_url is specified
assert_eq!(
"https://doc-example-bucket.s3.eu-west-1.amazonaws.com",
endpoint_uri.as_os_str()
);
let endpoint_auth_scheme = resolved_endpoint.auth_scheme().unwrap();
let signing_region = endpoint_auth_scheme.signing_region();
//signing region is still the region provided
assert_eq!(signing_region, "us-east-1");
}

#[test]
fn test_fips_dual_stack() {
let endpoint_config = EndpointConfig::new("eu-west-1").use_fips(true).use_dual_stack(true);
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ fn create_client_for_bucket(
endpoint_config = endpoint_config.region(&region_to_try);

if let Some(uri) = endpoint_url {
if user_provided_region {
if !user_provided_region {
tracing::warn!(
"endpoint specified but region unspecified. using {} as the signing region.",
region_to_try
Expand Down

0 comments on commit 63e4a74

Please sign in to comment.