From 706723954d6ef725ffad28cb2024b5207ad25f5e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 21 May 2020 00:13:38 +0000 Subject: [PATCH] Sort roles in keystone token Closes-bug: 1879359 https://bugs.launchpad.net/tempest/+bug/1879359 Sorts the roles in the scoped tokens so that the test case does not fail Change-Id: Iac94eab78035a9b0f3926bd7da237ae4f5fb68d8 --- tempest/api/identity/v3/test_tokens.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tempest/api/identity/v3/test_tokens.py b/tempest/api/identity/v3/test_tokens.py index fa1c47ffc4..cb05f39156 100644 --- a/tempest/api/identity/v3/test_tokens.py +++ b/tempest/api/identity/v3/test_tokens.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import operator + from oslo_utils import timeutils import six @@ -40,6 +42,15 @@ class TokensV3Test(base.BaseIdentityV3Test): authenticated_token = self.non_admin_client.show_token( subject_token)['token'] # sanity checking to make sure they are indeed the same token + # If there are roles in the token, sort the roles + authenticated_token_roles = authenticated_token.get("roles") + if authenticated_token_roles: + authenticated_token["roles"] = authenticated_token_roles.sort( + key=operator.itemgetter('id')) + token_body_roles = token_body.get("roles") + if token_body_roles: + token_body["roles"] = token_body_roles.sort( + key=operator.itemgetter('id')) self.assertEqual(authenticated_token, token_body) # test to see if token has been properly authenticated self.assertEqual(authenticated_token['user']['id'], user_id)