Keystone - List user groups 'membership_expires_at' attribute

With the introduction of expiring group memberships, there is a
new attribute `membership_expires_at` when listing user groups.
This patch updates the test to check the attribute and then
ignore it for group dict comparison.

Change-Id: I4294a879071dde07e5eb1da4df133de8032e1059
Partial-Bug: 1809116
This commit is contained in:
Kristi Nikolla
2020-03-24 08:22:40 -04:00
parent c8058d0c13
commit 30638b53a4

View File

@@ -114,6 +114,13 @@ class GroupsV3TestJSON(base.BaseIdentityV3AdminTest):
self.groups_client.add_group_user(group['id'], user['id'])
# list groups which user belongs to
user_groups = self.users_client.list_user_groups(user['id'])['groups']
# The `membership_expires_at` attribute is present when listing user
# group memberships, and is not an attribute of the groups themselves.
# Therefore we remove it from the comparison.
for g in user_groups:
if 'membership_expires_at' in g:
self.assertIsNone(g['membership_expires_at'])
del(g['membership_expires_at'])
self.assertEqual(sorted(groups, key=lambda k: k['name']),
sorted(user_groups, key=lambda k: k['name']))
self.assertEqual(2, len(user_groups))