Merge pull request #2909 from oliparcol/bug/2759
S3 - Allow keys to start with leading slashes
This commit is contained in:
commit
efbb9c54a5
3 changed files with 25 additions and 2 deletions
|
|
@ -3747,6 +3747,28 @@ def test_root_dir_with_empty_name_works():
|
|||
store_and_read_back_a_key("/")
|
||||
|
||||
|
||||
@parameterized(["mybucket", "my.bucket"])
|
||||
@mock_s3
|
||||
def test_leading_slashes_not_removed(bucket_name):
|
||||
"""Make sure that leading slashes are not removed internally."""
|
||||
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
|
||||
uploaded_key = "/key"
|
||||
invalid_key_1 = "key"
|
||||
invalid_key_2 = "//key"
|
||||
|
||||
s3.put_object(Bucket=bucket_name, Key=uploaded_key, Body=b"Some body")
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
s3.get_object(Bucket=bucket_name, Key=invalid_key_1)
|
||||
e.exception.response["Error"]["Code"].should.equal("NoSuchKey")
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
s3.get_object(Bucket=bucket_name, Key=invalid_key_2)
|
||||
e.exception.response["Error"]["Code"].should.equal("NoSuchKey")
|
||||
|
||||
|
||||
@parameterized(
|
||||
[("foo/bar/baz",), ("foo",), ("foo/run_dt%3D2019-01-01%252012%253A30%253A00",)]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue