From c4cc83c5e7083cad04f8fb9f620b03b5b73e3087 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Wed, 13 Aug 2025 17:52:13 +0100 Subject: [PATCH] s3api compat tests: stop asserting DisplayName in Owner S3 stopped returning DisplayNamme in the Owner field of object listings [1], so the tests need to stop asserting that it is present. Further work is needed to drop DisplayName from the Swift s3api responses [2]. [1] https://docs.aws.amazon.com/AmazonS3/latest/API/API_Owner.html [2] https://bugs.launchpad.net/swift/+bug/2120622 Change-Id: Ia915a65313394910c74ae826c912b5549e833a7b Signed-off-by: Alistair Coles --- test/s3api/__init__.py | 6 ++++++ test/s3api/test_service.py | 9 ++------- test/s3api/test_versioning.py | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/s3api/__init__.py b/test/s3api/__init__.py index bef0f4b1d8..d866978cdb 100644 --- a/test/s3api/__init__.py +++ b/test/s3api/__init__.py @@ -266,6 +266,12 @@ class BaseS3TestCase(BaseS3Mixin, unittest.TestCase): else: self.clear_account(client) + def check_owner(self, owner): + # as of July 2025, S3 may or may not send DisplayName + # https://docs.aws.amazon.com/AmazonS3/latest/API/API_Owner.html + owner.pop('DisplayName', None) + self.assertEqual(['ID'], list(owner.keys())) + class BaseS3TestCaseWithBucket(BaseS3Mixin, unittest.TestCase): @classmethod diff --git a/test/s3api/test_service.py b/test/s3api/test_service.py index e03b54cf26..e1d903f550 100644 --- a/test/s3api/test_service.py +++ b/test/s3api/test_service.py @@ -21,14 +21,12 @@ from test.s3api import BaseS3TestCase, ConfigError, \ class TestGetServiceSigV4(BaseS3TestCase): def _do_test_empty_service(self, client): - access_key = client._request_signer._credentials.access_key resp = client.list_buckets() self.assertEqual(200, resp['ResponseMetadata']['HTTPStatusCode']) self.assertEqual([], resp['Buckets']) self.assertIn('x-amz-request-id', resp['ResponseMetadata']['HTTPHeaders']) - self.assertIn('DisplayName', resp['Owner']) - self.assertEqual(access_key, resp['Owner']['DisplayName']) + self.check_owner(resp['Owner']) self.assertIn('ID', resp['Owner']) def test_empty_service(self): @@ -59,10 +57,7 @@ class TestGetServiceSigV4(BaseS3TestCase): for bucket in resp['Buckets'])) self.assertIn('x-amz-request-id', resp['ResponseMetadata']['HTTPHeaders']) - self.assertIn('DisplayName', resp['Owner']) - access_key = client._request_signer._credentials.access_key - self.assertEqual(access_key, resp['Owner']['DisplayName']) - self.assertIn('ID', resp['Owner']) + self.check_owner(resp['Owner']) def test_service_with_buckets(self): client = self.get_s3_client(1) diff --git a/test/s3api/test_versioning.py b/test/s3api/test_versioning.py index 9148a11d47..9dab49b570 100644 --- a/test/s3api/test_versioning.py +++ b/test/s3api/test_versioning.py @@ -670,9 +670,9 @@ class TestObjectVersioning(BaseS3TestCase): objs = resp.get('Contents', []) for obj in objs: owner = obj.pop('Owner') - self._sanitize_obj_listing(obj) # one difference seems to be the Owner key - self.assertEqual({'DisplayName', 'ID'}, set(owner.keys())) + self.check_owner(owner) + self._sanitize_obj_listing(obj) self.assertEqual(expected, objs) resp = self.client.list_objects_v2(Bucket=self.bucket_name) objs = resp.get('Contents', [])