From 19bfab2dd4faf3b51286657380d4e9e69acb188b Mon Sep 17 00:00:00 2001 From: Victor Sergeyev Date: Thu, 31 Oct 2013 15:56:22 +0200 Subject: [PATCH] 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 --- tuskarclient/client.py | 6 ++++-- tuskarclient/tests/test_client.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tuskarclient/client.py b/tuskarclient/client.py index e4038d1..14aa4cd 100644 --- a/tuskarclient/client.py +++ b/tuskarclient/client.py @@ -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 diff --git a/tuskarclient/tests/test_client.py b/tuskarclient/tests/test_client.py index 48b27e1..4b520a7 100644 --- a/tuskarclient/tests/test_client.py +++ b/tuskarclient/tests/test_client.py @@ -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)