From: Emin Date: Mon, 26 May 2025 10:58:14 +0000 (+0200) Subject: s3: Add tests for test_upload_part_copy_percent_encoded_key X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3e5ea3e725f89726e88e45a8cb2e9e7051c7be7c;p=s3-tests.git s3: Add tests for test_upload_part_copy_percent_encoded_key (cherry picked from commit f33d068f6df36251fc3b1e3996836e03279d4109) --- diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 61447d00..6e62aa73 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -17406,3 +17406,48 @@ def test_get_object_attributes(): assert response['StorageClass'] == 'STANDARD' assert 'ObjectParts' not in response + +@pytest.mark.s3 +def test_upload_part_copy_percent_encoded_key(): + + s3_client = get_client() + bucket_name = get_new_bucket() + key = "anyfile.txt" + encoded_key = "anyfilename%25.txt" + raw_key = "anyfilename%.txt" + + ## PutObject: the copy source + s3_client.put_object( + Bucket=bucket_name, + Key=encoded_key, + Body=b"foo", + ContentType="text/plain" + ) + + # Upload the target object (initial state) + s3_client.put_object( + Bucket=bucket_name, + Key=key, + Body=b"foo", + ContentType="text/plain" + ) + + # Initiate multipart upload + mp_response = s3_client.create_multipart_upload( + Bucket=bucket_name, + Key=key + ) + upload_id = mp_response["UploadId"] + + # The following operation is expected to fail + with pytest.raises(s3_client.exceptions.ClientError) as exc_info: + s3_client.upload_part_copy( + Bucket=bucket_name, + Key=key, + PartNumber=1, + UploadId=upload_id, + CopySource={'Bucket': bucket_name, 'Key': raw_key} + ) + + error = exc_info.value.response["Error"] + assert error["Code"] == "InvalidArgument" \ No newline at end of file