Skip to content

Commit

Permalink
explicit virtual addressing presigning bug (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlm6693 authored Dec 4, 2023
1 parent 98b6d34 commit 4b72854
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions botocore/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,4 +863,6 @@ def _should_use_global_endpoint(client):
and client.meta.config.region_name == 'us-east-1'
):
return False
if s3_config.get('addressing_style') == 'virtual':
return False
return True
40 changes: 40 additions & 0 deletions tests/functional/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,46 @@ def _addressing_for_presigned_url_test_cases():
expected_url="https://s3.us-west-2.amazonaws.com/foo.b.biz/key",
)

# virtual style addressing expicitly requested always uses
# regional endpoints except for us-east-1 and aws-global
yield dict(
region="us-west-2",
bucket="bucket",
key="key",
signature_version="s3",
s3_config={"addressing_style": "virtual"},
expected_url="https://bucket.s3.us-west-2.amazonaws.com/key",
)
yield dict(
region="us-east-2",
bucket="bucket",
key="key",
signature_version="s3v4",
s3_config={"addressing_style": "virtual"},
expected_url="https://bucket.s3.us-east-2.amazonaws.com/key",
)
yield dict(
region="us-west-2",
bucket="bucket",
key="key",
s3_config={"addressing_style": "virtual"},
expected_url="https://bucket.s3.us-west-2.amazonaws.com/key",
)
yield dict(
region="us-east-1",
bucket="bucket",
key="key",
s3_config={"addressing_style": "virtual"},
expected_url="https://bucket.s3.amazonaws.com/key",
)
yield dict(
region="aws-global",
bucket="bucket",
key="key",
s3_config={"addressing_style": "virtual"},
expected_url="https://bucket.s3.amazonaws.com/key",
)


@pytest.mark.parametrize(
"test_case", _addressing_for_presigned_url_test_cases()
Expand Down

0 comments on commit 4b72854

Please sign in to comment.