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 <alistairncoles@gmail.com>
This commit is contained in:
Alistair Coles
2025-08-13 17:52:13 +01:00
parent bdb052b59b
commit c4cc83c5e7
3 changed files with 10 additions and 9 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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', [])