Fix handling of values obtained from Keystone

The auth token and endpoint values obtained from Keystone used to be
silently ignored, because _get_client_with_token() function referred to
them using keyword argument names different from ones we called it with.

To fix it, moved `token` and `endpoint` to keyword arguments as
 `os_auth_token` and `tuskar_url` in _get_client_with_credentials().
Test modified.

Change-Id: I1011571de566ad18e31b905971f38105279561bd
Closes-Bug: #1246720
This commit is contained in:
Victor Sergeyev 2013-10-31 15:56:22 +02:00
parent efc9c0d51b
commit 19bfab2dd4
2 changed files with 8 additions and 4 deletions

View File

@ -94,11 +94,13 @@ def _get_client_with_credentials(api_version, **kwargs):
# test if we have all needed parameters
if (username and password and auth_url and
(tenant_id or tenant_name)):
# obtain a user token and API endpoint from keystone
token, endpoint = _get_token_and_endpoint(**kwargs)
kwargs['os_auth_token'] = token
kwargs['tuskar_url'] = endpoint
# call for a client with token and endpoint
return _get_client_with_token(api_version, endpoint=endpoint,
token=token, **kwargs)
return _get_client_with_token(api_version, **kwargs)
# returns None if we do not have needed parameters
else:
return None

View File

@ -194,9 +194,11 @@ class ClientGetClientWithCredentialsTest(tutils.TestCase):
'mocked client'
)
mocked_get_token_and_endpoint.assert_called_with(**kwargs)
del kwargs['tuskar_url']
del kwargs['os_auth_token']
mocked_get_client_with_token.assert_called_with(api_version,
token='token',
endpoint='endpoint',
os_auth_token='token',
tuskar_url='endpoint',
**kwargs)