diff --git a/saharaclient/api/client.py b/saharaclient/api/client.py index 4f95b389..3c5bfc48 100644 --- a/saharaclient/api/client.py +++ b/saharaclient/api/client.py @@ -76,10 +76,14 @@ class Client(object): verify = cacert session = keystone_session.Session(verify=verify) - service_type = self._determine_service_type(session, - auth, - service_type, - endpoint_type) + + if not auth: + auth = session.auth + + service_type = self._determine_service_type(session, + auth, + service_type, + endpoint_type) kwargs['user_agent'] = USER_AGENT kwargs.setdefault('interface', endpoint_type) diff --git a/saharaclient/tests/unit/nova/test_shell.py b/saharaclient/tests/unit/nova/test_shell.py index c9572ae5..04034190 100644 --- a/saharaclient/tests/unit/nova/test_shell.py +++ b/saharaclient/tests/unit/nova/test_shell.py @@ -353,15 +353,14 @@ class ShellTestKeystoneV3(ShellTest): '' ]) - mock_session_class_name = 'keystoneclient.adapter.LegacyJsonAdapter' + mock_get_service_type_method_name = ( + 'saharaclient.api.client.Client._determine_service_type') mock_job_executions_class_name = ( 'saharaclient.api.job_executions.JobExecutionsManager') - with mock.patch(mock_session_class_name) as mock_session: + with mock.patch(mock_get_service_type_method_name) as mock_st: with mock.patch(mock_job_executions_class_name): - ms = mock_session.return_value - ms.session.get_endpoint.return_value = 'http://no.where' - + mock_st.return_value = 'data-processing' self.make_env() stdout, stderr = self.shell('job-list') self.assertEqual((stdout + stderr), expected)