Merge "Sort roles in keystone token"

This commit is contained in:
Zuul 2020-05-28 00:51:36 +00:00 committed by Gerrit Code Review
commit 17bf0e1d3b
1 changed files with 11 additions and 0 deletions

View File

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