Merge "Fix indentation for oauth context"
This commit is contained in:
commit
f4e402f631
|
@ -85,6 +85,8 @@ def token_to_auth_context(token):
|
|||
auth_context['trustor_id'] = token.trustor_user_id
|
||||
auth_context['trustee_id'] = token.trustee_user_id
|
||||
else:
|
||||
# NOTE(lbragstad): These variables will already be set to None but we
|
||||
# add the else statement here for readability.
|
||||
auth_context['trust_id'] = None
|
||||
auth_context['trustor_id'] = None
|
||||
auth_context['trustee_id'] = None
|
||||
|
@ -95,8 +97,13 @@ def token_to_auth_context(token):
|
|||
|
||||
if token.oauth_scoped:
|
||||
auth_context['is_delegated_auth'] = True
|
||||
auth_context['consumer_id'] = token.oauth_consumer_id
|
||||
auth_context['access_token_id'] = token.oauth_access_token_id
|
||||
auth_context['consumer_id'] = token.oauth_consumer_id
|
||||
auth_context['access_token_id'] = token.oauth_access_token_id
|
||||
else:
|
||||
# NOTE(lbragstad): These variables will already be set to None but we
|
||||
# add the else statement here for readability.
|
||||
auth_context['consumer_id'] = None
|
||||
auth_context['access_token_id'] = None
|
||||
|
||||
if token.is_federated_user:
|
||||
auth_context['group_ids'] = token.federation_group_ids
|
||||
|
|
|
@ -118,6 +118,30 @@ class TestTokenToAuthContext(unit.BaseTestCase):
|
|||
|
||||
self.assertItemsEqual(group_ids, auth_context['group_ids'])
|
||||
|
||||
def test_oauth_variables_set_for_oauth_token(self):
|
||||
token_data = copy.deepcopy(test_token_provider.SAMPLE_V3_TOKEN)
|
||||
access_token_id = uuid.uuid4().hex
|
||||
consumer_id = uuid.uuid4().hex
|
||||
token_data['token']['OS-OAUTH1'] = {'access_token_id': access_token_id,
|
||||
'consumer_id': consumer_id}
|
||||
token = token_model.KeystoneToken(token_id=uuid.uuid4().hex,
|
||||
token_data=token_data)
|
||||
|
||||
auth_context = authorization.token_to_auth_context(token)
|
||||
|
||||
self.assertEqual(access_token_id, auth_context['access_token_id'])
|
||||
self.assertEqual(consumer_id, auth_context['consumer_id'])
|
||||
|
||||
def test_oauth_variables_not_set(self):
|
||||
token_data = copy.deepcopy(test_token_provider.SAMPLE_V3_TOKEN)
|
||||
token = token_model.KeystoneToken(token_id=uuid.uuid4().hex,
|
||||
token_data=token_data)
|
||||
|
||||
auth_context = authorization.token_to_auth_context(token)
|
||||
|
||||
self.assertIsNone(auth_context['access_token_id'])
|
||||
self.assertIsNone(auth_context['consumer_id'])
|
||||
|
||||
def test_token_is_not_KeystoneToken_raises_exception(self):
|
||||
# If the token isn't a KeystoneToken then an UnexpectedError exception
|
||||
# is raised.
|
||||
|
|
Loading…
Reference in New Issue