From e8f6584401de18bad0e7577b61ba2ccee0de3dac Mon Sep 17 00:00:00 2001 From: Morgan Fainberg Date: Wed, 18 May 2016 14:49:21 -0700 Subject: [PATCH] Enable py3 testing for Fernet token provider Enable the python3 testing for the fernet token provider. Change-Id: I31463d71098da1b009501a3dc40132a15a52c2a3 --- keystone/tests/unit/token/test_fernet_provider.py | 2 +- keystone/token/providers/fernet/token_formatters.py | 5 ++++- tests-py3-blacklist.txt | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/keystone/tests/unit/token/test_fernet_provider.py b/keystone/tests/unit/token/test_fernet_provider.py index 1cadcd4a2f..f6194f9c32 100644 --- a/keystone/tests/unit/token/test_fernet_provider.py +++ b/keystone/tests/unit/token/test_fernet_provider.py @@ -149,7 +149,7 @@ class TestValidate(unit.TestCase): 'protocol': {'id': protocol, }, }, } - self.assertEqual(exp_user_info, token['user']) + self.assertDictEqual(exp_user_info, token['user']) def test_validate_v3_token_trust(self): # Check the trust fields in the token result when use validate_v3_token diff --git a/keystone/token/providers/fernet/token_formatters.py b/keystone/token/providers/fernet/token_formatters.py index 18f51e5583..4afe068032 100644 --- a/keystone/token/providers/fernet/token_formatters.py +++ b/keystone/token/providers/fernet/token_formatters.py @@ -20,6 +20,7 @@ import msgpack from oslo_config import cfg from oslo_log import log from oslo_utils import timeutils +import six from six.moves import map from six.moves import urllib @@ -536,7 +537,9 @@ class FederatedUnscopedPayload(BasePayload): idp_id = cls.convert_uuid_bytes_to_hex(idp_id) else: idp_id = idp_id.decode('utf-8') - protocol_id = payload[4].decode('utf-8') + protocol_id = payload[4] + if isinstance(protocol_id, six.binary_type): + protocol_id = protocol_id.decode('utf-8') expires_at_str = cls._convert_float_to_time_string(payload[5]) audit_ids = list(map(provider.base64_encode, payload[6])) federated_info = dict(group_ids=group_ids, idp_id=idp_id, diff --git a/tests-py3-blacklist.txt b/tests-py3-blacklist.txt index 348847349d..95abf00da7 100644 --- a/tests-py3-blacklist.txt +++ b/tests-py3-blacklist.txt @@ -1,3 +1,2 @@ keystone.tests.unit.test_v3_auth keystone.tests.unit.test_v3_oauth1 -keystone.tests.unit.token.test_fernet_provider