"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/unit/token/test_fernet_provider.py" between
keystone-15.0.0.tar.gz and keystone-15.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 "Stein" series (maintained release).

test_fernet_provider.py  (keystone-15.0.0):test_fernet_provider.py  (keystone-15.0.1)
skipping to change at line 285 skipping to change at line 285
# Generate expected_time_str using the same time float. Using # Generate expected_time_str using the same time float. Using
# original_time_str from utils.isotime will occasionally fail due to # original_time_str from utils.isotime will occasionally fail due to
# floating point rounding differences. # floating point rounding differences.
time_object = datetime.datetime.utcfromtimestamp(actual_time_float) time_object = datetime.datetime.utcfromtimestamp(actual_time_float)
expected_time_str = utils.isotime(time_object, subsecond=True) expected_time_str = utils.isotime(time_object, subsecond=True)
actual_time_str = payload_cls._convert_float_to_time_string( actual_time_str = payload_cls._convert_float_to_time_string(
actual_time_float) actual_time_float)
self.assertEqual(expected_time_str, actual_time_str) self.assertEqual(expected_time_str, actual_time_str)
def test_convert_or_decode_uuid_bytes(self):
payload_cls = token_formatters.BasePayload
expected_hex_uuid = uuid.uuid4().hex
uuid_obj = uuid.UUID(expected_hex_uuid)
expected_uuid_in_bytes = uuid_obj.bytes
actual_hex_uuid = payload_cls._convert_or_decode(
is_stored_as_bytes=True,
value=expected_uuid_in_bytes
)
self.assertEqual(expected_hex_uuid, actual_hex_uuid)
def test_convert_or_decode_binary_type(self):
payload_cls = token_formatters.BasePayload
expected_hex_uuid = uuid.uuid4().hex
actual_hex_uuid = payload_cls._convert_or_decode(
is_stored_as_bytes=False,
value=expected_hex_uuid.encode('utf-8')
)
self.assertEqual(expected_hex_uuid, actual_hex_uuid)
def test_convert_or_decode_text_type(self):
payload_cls = token_formatters.BasePayload
expected_hex_uuid = uuid.uuid4().hex
actual_hex_uuid = payload_cls._convert_or_decode(
is_stored_as_bytes=False,
value=expected_hex_uuid
)
self.assertEqual(expected_hex_uuid, actual_hex_uuid)
def _test_payload(self, payload_class, exp_user_id=None, exp_methods=None, def _test_payload(self, payload_class, exp_user_id=None, exp_methods=None,
exp_system=None, exp_project_id=None, exp_domain_id=None, exp_system=None, exp_project_id=None, exp_domain_id=None,
exp_trust_id=None, exp_federated_group_ids=None, exp_trust_id=None, exp_federated_group_ids=None,
exp_identity_provider_id=None, exp_protocol_id=None, exp_identity_provider_id=None, exp_protocol_id=None,
exp_access_token_id=None, exp_app_cred_id=None): exp_access_token_id=None, exp_app_cred_id=None,
encode_ids=False):
def _encode_id(value):
if value is not None and six.text_type(value) and encode_ids:
return value.encode('utf-8')
return value
exp_user_id = exp_user_id or uuid.uuid4().hex exp_user_id = exp_user_id or uuid.uuid4().hex
exp_methods = exp_methods or ['password'] exp_methods = exp_methods or ['password']
exp_expires_at = utils.isotime(timeutils.utcnow(), subsecond=True) exp_expires_at = utils.isotime(timeutils.utcnow(), subsecond=True)
exp_audit_ids = [provider.random_urlsafe_str()] exp_audit_ids = [provider.random_urlsafe_str()]
payload = payload_class.assemble( payload = payload_class.assemble(
exp_user_id, exp_methods, exp_system, exp_project_id, _encode_id(exp_user_id),
exp_domain_id, exp_expires_at, exp_audit_ids, exp_trust_id, exp_methods,
exp_federated_group_ids, exp_identity_provider_id, exp_protocol_id, _encode_id(exp_system),
exp_access_token_id, exp_app_cred_id) _encode_id(exp_project_id),
exp_domain_id,
exp_expires_at,
exp_audit_ids,
exp_trust_id,
_encode_id(exp_federated_group_ids),
_encode_id(exp_identity_provider_id),
exp_protocol_id,
_encode_id(exp_access_token_id),
_encode_id(exp_app_cred_id))
(user_id, methods, system, project_id, (user_id, methods, system, project_id,
domain_id, expires_at, audit_ids, domain_id, expires_at, audit_ids,
trust_id, federated_group_ids, identity_provider_id, protocol_id, trust_id, federated_group_ids, identity_provider_id, protocol_id,
access_token_id, app_cred_id) = payload_class.disassemble(payload) access_token_id, app_cred_id) = payload_class.disassemble(payload)
self.assertEqual(exp_user_id, user_id) self.assertEqual(exp_user_id, user_id)
self.assertEqual(exp_methods, methods) self.assertEqual(exp_methods, methods)
self.assertTimestampsEqual(exp_expires_at, expires_at) self.assertTimestampsEqual(exp_expires_at, expires_at)
self.assertEqual(exp_audit_ids, audit_ids) self.assertEqual(exp_audit_ids, audit_ids)
skipping to change at line 362 skipping to change at line 414
def test_project_scoped_payload_with_non_uuid_ids(self): def test_project_scoped_payload_with_non_uuid_ids(self):
self._test_payload(token_formatters.ProjectScopedPayload, self._test_payload(token_formatters.ProjectScopedPayload,
exp_user_id='someNonUuidUserId', exp_user_id='someNonUuidUserId',
exp_project_id='someNonUuidProjectId') exp_project_id='someNonUuidProjectId')
def test_project_scoped_payload_with_16_char_non_uuid_ids(self): def test_project_scoped_payload_with_16_char_non_uuid_ids(self):
self._test_payload(token_formatters.ProjectScopedPayload, self._test_payload(token_formatters.ProjectScopedPayload,
exp_user_id='0123456789abcdef', exp_user_id='0123456789abcdef',
exp_project_id='0123456789abcdef') exp_project_id='0123456789abcdef')
def test_project_scoped_payload_with_binary_encoded_ids(self):
self._test_payload(token_formatters.ProjectScopedPayload,
exp_user_id='someNonUuidUserId',
exp_project_id='someNonUuidProjectId',
encode_ids=True)
def test_domain_scoped_payload_with_non_uuid_user_id(self): def test_domain_scoped_payload_with_non_uuid_user_id(self):
self._test_payload(token_formatters.DomainScopedPayload, self._test_payload(token_formatters.DomainScopedPayload,
exp_user_id='nonUuidUserId', exp_user_id='nonUuidUserId',
exp_domain_id=uuid.uuid4().hex) exp_domain_id=uuid.uuid4().hex)
def test_domain_scoped_payload_with_16_char_non_uuid_user_id(self): def test_domain_scoped_payload_with_16_char_non_uuid_user_id(self):
self._test_payload(token_formatters.DomainScopedPayload, self._test_payload(token_formatters.DomainScopedPayload,
exp_user_id='0123456789abcdef', exp_user_id='0123456789abcdef',
exp_domain_id=uuid.uuid4().hex) exp_domain_id=uuid.uuid4().hex)
 End of changes. 4 change blocks. 
5 lines changed or deleted 63 lines changed or added

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