]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
s3: Add tests for test_upload_part_copy_percent_encoded_key
authorEmin <emin.sunacoglu@clyso.com>
Mon, 26 May 2025 10:58:14 +0000 (12:58 +0200)
committerCasey Bodley <cbodley@redhat.com>
Thu, 19 Jun 2025 16:18:55 +0000 (12:18 -0400)
(cherry picked from commit f33d068f6df36251fc3b1e3996836e03279d4109)

s3tests_boto3/functional/test_s3.py

index 61447d00d6c08004d6d45e37d9e840bd12bf2580..6e62aa737eaaec0cc5297a05cb6eb9d0835c00c4 100644 (file)
@@ -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