From 0bf337eedf24967c48eb1c959aa01bd72f54c2d7 Mon Sep 17 00:00:00 2001 From: shreyanshjain7174 Date: Fri, 10 Jan 2025 06:35:55 -0600 Subject: [PATCH] Add test case to verify S3 object tagging during multipart upload - Implemented a test to validate that tags applied during multipart uploads are retained and retrievable. Signed-off-by: shreyanshjain7174 --- s3tests_boto3/functional/test_s3.py | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 4929ea3a..c35f77d1 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -11258,6 +11258,38 @@ def test_put_obj_with_tags(): tagset = tagset assert response_tagset == tagset +@pytest.mark.tagging +@pytest.mark.fails_on_dbstore +def test_multipart_obj_tagging(): + from urllib import parse + import os + + key = "testputtags" + bucket_name = get_new_bucket() + file_path = "/tmp/random-content.tmp"; open(file_path, "wb").write(os.urandom(300 * 1024 * 1024)) + client = get_client() + + # Define tags + input_tagset = _create_simple_tagset(2) + tagging = parse.urlencode({tag['Key']: tag['Value'] for tag in input_tagset['TagSet']}) + + # Upload object using 'upload_file' with tags + client.upload_file( + Filename=file_path, + Bucket=bucket_name, + Key=key, + ExtraArgs={"Tagging": tagging} + ) + + # Retrieve tags and verify + response = client.get_object_tagging(Bucket=bucket_name, Key=key) + try: + assert response["TagSet"] == input_tagset["TagSet"] + except KeyError as e: + assert False, f"Test failed: Tags retrieved do not match the input tags." + os.remove(file_path) + print("Test passed: Tags retrieved successfully match the input tags.") + def _make_arn_resource(path="*"): return "arn:aws:s3:::{}".format(path)