Merge "Sort roles in keystone token"
diff --git a/tempest/api/identity/v3/test_tokens.py b/tempest/api/identity/v3/test_tokens.py
index fa1c47f..cb05f39 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 @@
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)