S3 - Return tag-count as string (#5258)

This commit is contained in:
Bert Blommers 2022-06-23 20:38:22 +00:00 committed by GitHub
parent adaa7623c5
commit 7d8c05ebee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -291,7 +291,7 @@ class FakeKey(BaseModel, ManagedState):
res["x-amz-object-lock-mode"] = self.lock_mode
tags = s3_backends["global"].tagger.get_tag_dict_for_resource(self.arn)
if tags:
res["x-amz-tagging-count"] = len(tags.keys())
res["x-amz-tagging-count"] = str(len(tags.keys()))
return res

View File

@ -1,4 +1,5 @@
import boto3
import requests
import pytest
import sure # noqa # pylint: disable=unused-import
@ -455,3 +456,18 @@ def test_objects_tagging_with_same_key_name():
assert variable1 == "one"
assert variable2 == "two"
@mock_s3
def test_generate_url_for_tagged_object():
s3 = boto3.client("s3")
s3.create_bucket(Bucket="my-bucket")
s3.put_object(
Bucket="my-bucket", Key="test.txt", Body=b"abc", Tagging="MyTag=value"
)
url = s3.generate_presigned_url(
"get_object", Params={"Bucket": "my-bucket", "Key": "test.txt"}
)
response = requests.get(url)
response.content.should.equal(b"abc")
response.headers["x-amz-tagging-count"].should.equal("1")