Fix:s3 List Object response:delimiter (#3254)

* Fix:s3 List Object delimiter in response

* fixed tests

* fixed failed tests

Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
usmangani1 2020-09-21 20:51:18 +05:30 committed by GitHub
parent 1022aa0968
commit 0b9903a3df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -1774,7 +1774,9 @@ S3_BUCKET_GET_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
<Prefix>{{ prefix }}</Prefix>
{% endif %}
<MaxKeys>{{ max_keys }}</MaxKeys>
<Delimiter>{{ delimiter }}</Delimiter>
{% if delimiter %}
<Delimiter>{{ delimiter }}</Delimiter>
{% endif %}
<IsTruncated>{{ is_truncated }}</IsTruncated>
{% if next_marker %}
<NextMarker>{{ next_marker }}</NextMarker>

View File

@ -1709,6 +1709,17 @@ def test_website_redirect_location():
resp["WebsiteRedirectLocation"].should.equal(url)
@mock_s3
def test_delimiter_optional_in_response():
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3.create_bucket(Bucket="mybucket")
s3.put_object(Bucket="mybucket", Key="one", Body=b"1")
resp = s3.list_objects(Bucket="mybucket", MaxKeys=1)
assert resp.get("Delimiter") is None
resp = s3.list_objects(Bucket="mybucket", MaxKeys=1, Delimiter="/")
assert resp.get("Delimiter") == "/"
@mock_s3
def test_boto3_list_objects_truncated_response():
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@ -1725,7 +1736,7 @@ def test_boto3_list_objects_truncated_response():
assert resp["MaxKeys"] == 1
assert resp["IsTruncated"] == True
assert resp.get("Prefix") is None
assert resp["Delimiter"] == "None"
assert resp.get("Delimiter") is None
assert "NextMarker" in resp
next_marker = resp["NextMarker"]
@ -1738,7 +1749,7 @@ def test_boto3_list_objects_truncated_response():
assert resp["MaxKeys"] == 1
assert resp["IsTruncated"] == True
assert resp.get("Prefix") is None
assert resp["Delimiter"] == "None"
assert resp.get("Delimiter") is None
assert "NextMarker" in resp
next_marker = resp["NextMarker"]
@ -1751,7 +1762,7 @@ def test_boto3_list_objects_truncated_response():
assert resp["MaxKeys"] == 1
assert resp["IsTruncated"] == False
assert resp.get("Prefix") is None
assert resp["Delimiter"] == "None"
assert resp.get("Delimiter") is None
assert "NextMarker" not in resp