From cc13ed49848df6ad20ea978d1eb5c979e3bae51e Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Wed, 28 Jun 2023 13:12:54 +0530 Subject: [PATCH] Add testcase to verify obj mtime post setattrs Object mtime should not change for any attr changes unless its a copy operation. Verify the same using PutObjectACL op. Signed-off-by: Soumya Koduri (cherry picked from commit 10f3f7620dfb1077d1cc5ac16b20f75bcab6b02b) --- s3tests_boto3/functional/test_s3.py | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index f0348ea..6b1aa0a 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -3309,6 +3309,43 @@ def test_object_raw_get_object_acl(): assert status == 403 assert error_code == 'AccessDenied' +def test_object_put_acl_mtime(): + key = 'foo' + bucket_name = get_new_bucket() + # Enable versioning + check_configure_versioning_retry(bucket_name, "Enabled", "Enabled") + client = get_client() + + content = 'foooz' + client.put_object(Bucket=bucket_name, Key=key, Body=content) + + obj_response = client.head_object(Bucket=bucket_name, Key=key) + create_mtime = obj_response['LastModified'] + + response = client.list_objects(Bucket=bucket_name) + obj_list = response['Contents'][0] + _compare_dates(obj_list['LastModified'],create_mtime) + + response = client.list_object_versions(Bucket=bucket_name) + obj_list = response['Versions'][0] + _compare_dates(obj_list['LastModified'],create_mtime) + + # set acl + time.sleep(2) + client.put_object_acl(ACL='private',Bucket=bucket_name, Key=key) + + # mtime should match with create mtime + obj_response = client.head_object(Bucket=bucket_name, Key=key) + _compare_dates(create_mtime,obj_response['LastModified']) + + response = client.list_objects(Bucket=bucket_name) + obj_list = response['Contents'][0] + _compare_dates(obj_list['LastModified'],create_mtime) + + response = client.list_object_versions(Bucket=bucket_name) + obj_list = response['Versions'][0] + _compare_dates(obj_list['LastModified'],create_mtime) + def test_object_raw_authenticated(): bucket_name = _setup_bucket_object_acl('public-read', 'public-read')