Merge pull request #424 from psathyan/fix_check_grants

Improving check_grants reliability
This commit is contained in:
Ali Maredia 2022-01-18 17:02:35 -05:00 committed by GitHub
commit a38cdb1dd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4490,12 +4490,19 @@ def check_access_denied(fn, *args, **kwargs):
status = _get_status(e.response) status = _get_status(e.response)
eq(status, 403) eq(status, 403)
def check_grants(got, want): def check_grants(got, want):
""" """
Check that grants list in got matches the dictionaries in want, Check that grants list in got matches the dictionaries in want,
in any order. in any order.
""" """
eq(len(got), len(want)) eq(len(got), len(want))
# There are instances when got does not match due the order of item.
if got[0]["Grantee"].get("DisplayName"):
got.sort(key=lambda x: x["Grantee"].get("DisplayName"))
want.sort(key=lambda x: x["DisplayName"])
for g, w in zip(got, want): for g, w in zip(got, want):
w = dict(w) w = dict(w)
g = dict(g) g = dict(g)
@ -4507,6 +4514,7 @@ def check_grants(got, want):
eq(g['Grantee'].pop('EmailAddress', None), w['EmailAddress']) eq(g['Grantee'].pop('EmailAddress', None), w['EmailAddress'])
eq(g, {'Grantee': {}}) eq(g, {'Grantee': {}})
@attr(resource='bucket') @attr(resource='bucket')
@attr(method='get') @attr(method='get')
@attr(operation='default acl') @attr(operation='default acl')