"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/unit/token/test_fernet_provider.py" between
keystone-16.0.0.tar.gz and keystone-16.0.1.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Train" series (latest release).

test_fernet_provider.py  (keystone-16.0.0):test_fernet_provider.py  (keystone-16.0.1)
skipping to change at line 93 skipping to change at line 93
self.assertIsInstance(token.expires_at, str) self.assertIsInstance(token.expires_at, str)
self.assertIsInstance(token.issued_at, str) self.assertIsInstance(token.issued_at, str)
self.assertEqual(method_names, token.methods) self.assertEqual(method_names, token.methods)
self.assertEqual(user_ref['id'], token.user_id) self.assertEqual(user_ref['id'], token.user_id)
self.assertEqual(user_ref['name'], token.user['name']) self.assertEqual(user_ref['name'], token.user['name'])
self.assertDictEqual(domain_ref, token.user_domain) self.assertDictEqual(domain_ref, token.user_domain)
self.assertEqual( self.assertEqual(
user_ref['password_expires_at'], token.user['password_expires_at'] user_ref['password_expires_at'], token.user['password_expires_at']
) )
def test_validate_v3_token_federated_info(self): def _test_validate_v3_token_federted_info(self, group_ids):
# Check the user fields in the token result when use validate_v3_token # Check the user fields in the token result when use validate_v3_token
# when the token has federated info. # when the token has federated info.
domain_ref = unit.new_domain_ref() domain_ref = unit.new_domain_ref()
domain_ref = PROVIDERS.resource_api.create_domain( domain_ref = PROVIDERS.resource_api.create_domain(
domain_ref['id'], domain_ref domain_ref['id'], domain_ref
) )
user_ref = unit.new_user_ref(domain_ref['id']) user_ref = unit.new_user_ref(domain_ref['id'])
user_ref = PROVIDERS.identity_api.create_user(user_ref) user_ref = PROVIDERS.identity_api.create_user(user_ref)
method_names = ['mapped'] method_names = ['mapped']
group_ids = [uuid.uuid4().hex, ]
idp_id = uuid.uuid4().hex idp_id = uuid.uuid4().hex
idp_ref = { idp_ref = {
'id': idp_id, 'id': idp_id,
'description': uuid.uuid4().hex, 'description': uuid.uuid4().hex,
'enabled': True 'enabled': True
} }
self.federation_api.create_idp(idp_id, idp_ref) self.federation_api.create_idp(idp_id, idp_ref)
protocol = uuid.uuid4().hex protocol = uuid.uuid4().hex
auth_context_params = { auth_context_params = {
'user_id': user_ref['id'], 'user_id': user_ref['id'],
skipping to change at line 137 skipping to change at line 136
token = PROVIDERS.token_provider_api.validate_token(token.id) token = PROVIDERS.token_provider_api.validate_token(token.id)
self.assertEqual(user_ref['id'], token.user_id) self.assertEqual(user_ref['id'], token.user_id)
self.assertEqual(user_ref['name'], token.user['name']) self.assertEqual(user_ref['name'], token.user['name'])
self.assertDictEqual(domain_ref, token.user_domain) self.assertDictEqual(domain_ref, token.user_domain)
exp_group_ids = [{'id': group_id} for group_id in group_ids] exp_group_ids = [{'id': group_id} for group_id in group_ids]
self.assertEqual(exp_group_ids, token.federated_groups) self.assertEqual(exp_group_ids, token.federated_groups)
self.assertEqual(idp_id, token.identity_provider_id) self.assertEqual(idp_id, token.identity_provider_id)
self.assertEqual(protocol, token.protocol_id) self.assertEqual(protocol, token.protocol_id)
def test_validate_v3_token_federated_info(self):
# Check the user fields in the token result when use validate_v3_token
# when the token has federated info.
group_ids = [uuid.uuid4().hex, ]
self._test_validate_v3_token_federted_info(group_ids)
def test_validate_v3_token_federated_info_empty_group(self):
# check when federated users got empty group ids
self._test_validate_v3_token_federted_info([])
def test_validate_v3_token_trust(self): def test_validate_v3_token_trust(self):
# Check the trust fields in the token result when use validate_v3_token # Check the trust fields in the token result when use validate_v3_token
# when the token has trust info. # when the token has trust info.
domain_ref = unit.new_domain_ref() domain_ref = unit.new_domain_ref()
domain_ref = PROVIDERS.resource_api.create_domain( domain_ref = PROVIDERS.resource_api.create_domain(
domain_ref['id'], domain_ref domain_ref['id'], domain_ref
) )
user_ref = unit.new_user_ref(domain_ref['id']) user_ref = unit.new_user_ref(domain_ref['id'])
skipping to change at line 200 skipping to change at line 211
# When the token format isn't recognized, TokenNotFound is raised. # When the token format isn't recognized, TokenNotFound is raised.
# A uuid string isn't a valid Fernet token. # A uuid string isn't a valid Fernet token.
token_id = uuid.uuid4().hex token_id = uuid.uuid4().hex
self.assertRaises( self.assertRaises(
exception.TokenNotFound, exception.TokenNotFound,
PROVIDERS.token_provider_api.validate_token, PROVIDERS.token_provider_api.validate_token,
token_id token_id
) )
class TestValidateWithoutCache(TestValidate):
def config_overrides(self):
super(TestValidateWithoutCache, self).config_overrides()
self.config_fixture.config(group='token', caching=False)
self.config_fixture.config(group='token', cache_on_issue=False)
class TestTokenFormatter(unit.TestCase): class TestTokenFormatter(unit.TestCase):
def test_restore_padding(self): def test_restore_padding(self):
# 'a' will result in '==' padding, 'aa' will result in '=' padding, and # 'a' will result in '==' padding, 'aa' will result in '=' padding, and
# 'aaa' will result in no padding. # 'aaa' will result in no padding.
binary_to_test = [b'a', b'aa', b'aaa'] binary_to_test = [b'a', b'aa', b'aaa']
for binary in binary_to_test: for binary in binary_to_test:
# base64.urlsafe_b64encode takes six.binary_type and returns # base64.urlsafe_b64encode takes six.binary_type and returns
# six.binary_type. # six.binary_type.
encoded_string = base64.urlsafe_b64encode(binary) encoded_string = base64.urlsafe_b64encode(binary)
 End of changes. 4 change blocks. 
2 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)