Fixing getting mistral_url from keystone catalog

Closes-Bug: #1598018

Depends-On: I1b61bd1de6811a5f65c2375dde956aafe33445b2
Change-Id: I16f1a5ff412d98371dfaab863cb24b47438d2d1e
This commit is contained in:
Nikolay Mahotkin
2016-09-01 12:50:27 +03:00
parent a37b5fe562
commit b9e87ef863
2 changed files with 34 additions and 2 deletions

View File

@@ -58,8 +58,7 @@ def authenticate(mistral_url=None, username=None,
if service_type in catalog: if service_type in catalog:
service = catalog.get(service_type) service = catalog.get(service_type)
mistral_url = service[0].get( mistral_url = service[0].get('url') if service else None
endpoint_type) if service else None
return mistral_url, token, project_id, user_id return mistral_url, token, project_id, user_id

View File

@@ -32,6 +32,39 @@ PROFILER_HMAC_KEY = 'SECRET_HMAC_KEY'
class BaseClientTests(testtools.TestCase): class BaseClientTests(testtools.TestCase):
@mock.patch('keystoneclient.v3.client.Client')
def test_mistral_url_from_catalog(self, keystone_client_mock):
keystone_client_instance = keystone_client_mock.return_value
keystone_client_instance.auth_token = str(uuid.uuid4())
keystone_client_instance.project_id = str(uuid.uuid4())
keystone_client_instance.user_id = str(uuid.uuid4())
get_endpoints = mock.Mock()
get_endpoints.return_value = {
'workflowv2': [
{
'url': 'http://mistral_host:8989/v2',
'interface': 'public',
'region': None,
'region_id': None,
'id': '446eca511e8d45acae0924aea42a4c9f'
}
]
}
keystone_client_instance.service_catalog.get_endpoints = get_endpoints
mistralclient = client.client(
username='mistral',
project_name='mistral',
auth_url=AUTH_HTTP_URL,
service_type='workflowv2'
)
self.assertEqual(
'http://mistral_host:8989/v2',
mistralclient.http_client.base_url
)
@mock.patch('keystoneclient.v3.client.Client') @mock.patch('keystoneclient.v3.client.Client')
@mock.patch('mistralclient.api.httpclient.HTTPClient') @mock.patch('mistralclient.api.httpclient.HTTPClient')