Skip to content

Commit

Permalink
Add S3 tests to ensure dot segments are preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan343 committed Sep 5, 2024
1 parent ba9db7f commit 3a0a7b7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/functional/botocore/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2925,3 +2925,44 @@ def test_escape_keys_in_xml_put_bucket_lifecycle_configuration(self):
self.assertNotIn(b'my\r\n\rprefix', request.body)
self.assertIn(b'my

prefix', request.body)
self.assert_correct_content_md5(request)


@pytest.mark.parametrize(
"bucket, key, expected_path, expected_hostname",
[
(
"mybucket",
"../key.txt",
"/../key.txt",
"mybucket.s3.us-west-2.amazonaws.com",
),
(
"mybucket",
"foo/../key.txt",
"/foo/../key.txt",
"mybucket.s3.us-west-2.amazonaws.com",
),
(
"mybucket",
"foo/../../key.txt",
"/foo/../../key.txt",
"mybucket.s3.us-west-2.amazonaws.com",
),
],
)
def test_dot_segments_preserved_in_url_path(
patched_session, bucket, key, expected_path, expected_hostname
):
s3 = patched_session.create_client(
's3',
'us-west-2',
config=Config(
s3={"addressing_style": "virtual"},
),
)
with ClientHTTPStubber(s3) as http_stubber:
http_stubber.add_response()
s3.get_object(Bucket=bucket, Key=key)
url_parts = urlsplit(http_stubber.requests[0].url)
assert url_parts.path == expected_path
assert url_parts.hostname == expected_hostname

0 comments on commit 3a0a7b7

Please sign in to comment.