]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
check Owner/Initiator fields of ListMultipartUploads response
authorCasey Bodley <cbodley@redhat.com>
Fri, 29 Oct 2021 17:06:30 +0000 (13:06 -0400)
committerAli Maredia <amaredia@redhat.com>
Thu, 18 Nov 2021 19:32:20 +0000 (14:32 -0500)
new test case test_list_multipart_upload_owner() uses two different
users to initiate multipart uploads, then tests that
list_multipart_uploads() shows the correct user ids and display names
for each upload

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 490d0a4c4f91faf2a5213c95c4b92f7c3c94c878)

s3tests_boto3/functional/test_s3.py

index 2db2f817cddb6a24fc5d279ddf0c916938de4fe8..85d96d28ba5a31de5d4bbea26aee9844e002de07 100644 (file)
@@ -7319,6 +7319,55 @@ def test_list_multipart_upload():
     client.abort_multipart_upload(Bucket=bucket_name, Key=key, UploadId=upload_id2)
     client.abort_multipart_upload(Bucket=bucket_name, Key=key2, UploadId=upload_id3)
 
+@attr(resource='bucket')
+@attr(method='get')
+@attr(operation='list multipart uploads with different owners')
+@attr(assertion='successful')
+def test_list_multipart_upload_owner():
+    bucket_name = get_new_bucket()
+
+    client1 = get_client()
+    user1 = get_main_user_id()
+    name1 = get_main_display_name()
+
+    client2 = get_alt_client()
+    user2  = get_alt_user_id()
+    name2 = get_alt_display_name()
+
+    # add bucket acl for public read/write access
+    client1.put_bucket_acl(Bucket=bucket_name, ACL='public-read-write')
+
+    key1 = 'multipart1'
+    key2 = 'multipart2'
+    upload1 = client1.create_multipart_upload(Bucket=bucket_name, Key=key1)['UploadId']
+    try:
+        upload2 = client2.create_multipart_upload(Bucket=bucket_name, Key=key2)['UploadId']
+        try:
+            # match fields of an Upload from ListMultipartUploadsResult
+            def match(upload, key, uploadid, userid, username):
+                eq(upload['Key'], key)
+                eq(upload['UploadId'], uploadid)
+                eq(upload['Initiator']['ID'], userid)
+                eq(upload['Initiator']['DisplayName'], username)
+                eq(upload['Owner']['ID'], userid)
+                eq(upload['Owner']['DisplayName'], username)
+
+            # list uploads with client1
+            uploads1 = client1.list_multipart_uploads(Bucket=bucket_name)['Uploads']
+            eq(len(uploads1), 2)
+            match(uploads1[0], key1, upload1, user1, name1)
+            match(uploads1[1], key2, upload2, user2, name2)
+
+            # list uploads with client2
+            uploads2 = client2.list_multipart_uploads(Bucket=bucket_name)['Uploads']
+            eq(len(uploads2), 2)
+            match(uploads2[0], key1, upload1, user1, name1)
+            match(uploads2[1], key2, upload2, user2, name2)
+        finally:
+            client2.abort_multipart_upload(Bucket=bucket_name, Key=key2, UploadId=upload2)
+    finally:
+        client1.abort_multipart_upload(Bucket=bucket_name, Key=key1, UploadId=upload1)
+
 @attr(resource='object')
 @attr(method='put')
 @attr(operation='multi-part upload with missing part')