Fixing getting mistral_url from keystone catalog
Closes-Bug: #1598018 Depends-On: I1b61bd1de6811a5f65c2375dde956aafe33445b2 Change-Id: I16f1a5ff412d98371dfaab863cb24b47438d2d1e
This commit is contained in:
@@ -58,8 +58,7 @@ def authenticate(mistral_url=None, username=None,
|
||||
|
||||
if service_type in catalog:
|
||||
service = catalog.get(service_type)
|
||||
mistral_url = service[0].get(
|
||||
endpoint_type) if service else None
|
||||
mistral_url = service[0].get('url') if service else None
|
||||
|
||||
return mistral_url, token, project_id, user_id
|
||||
|
||||
|
@@ -32,6 +32,39 @@ PROFILER_HMAC_KEY = 'SECRET_HMAC_KEY'
|
||||
|
||||
|
||||
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('mistralclient.api.httpclient.HTTPClient')
|
||||
|
Reference in New Issue
Block a user