Merge "Always return the service name in the catalog"
This commit is contained in:
commit
ab063791d3
@ -293,7 +293,7 @@ class Catalog(catalog.Driver):
|
||||
service_type = endpoint.service['type']
|
||||
default_service = {
|
||||
'id': endpoint['id'],
|
||||
'name': endpoint.service['name'],
|
||||
'name': endpoint.service.extra.get('name', ''),
|
||||
'publicURL': ''
|
||||
}
|
||||
catalog.setdefault(region, {})
|
||||
@ -329,9 +329,7 @@ class Catalog(catalog.Driver):
|
||||
def make_v3_service(svc):
|
||||
eps = list(make_v3_endpoints(svc.endpoints))
|
||||
service = {'endpoints': eps, 'id': svc.id, 'type': svc.type}
|
||||
name = svc.extra.get('name')
|
||||
if name:
|
||||
service['name'] = name
|
||||
service['name'] = svc.extra.get('name', '')
|
||||
return service
|
||||
|
||||
return [make_v3_service(svc) for svc in services]
|
||||
|
@ -179,3 +179,33 @@ class TestV2CatalogAPISQL(tests.TestCase):
|
||||
self.assertEqual(1, len(catalog))
|
||||
# all three endpoints appear in the backend
|
||||
self.assertEqual(3, len(self.catalog_api.list_endpoints()))
|
||||
|
||||
def test_get_catalog_always_returns_service_name(self):
|
||||
user_id = uuid.uuid4().hex
|
||||
tenant_id = uuid.uuid4().hex
|
||||
|
||||
# create a service, with a name
|
||||
named_svc = {
|
||||
'id': uuid.uuid4().hex,
|
||||
'type': uuid.uuid4().hex,
|
||||
'name': uuid.uuid4().hex,
|
||||
}
|
||||
self.catalog_api.create_service(named_svc['id'], named_svc)
|
||||
endpoint = self.new_endpoint_ref(service_id=named_svc['id'])
|
||||
self.catalog_api.create_endpoint(endpoint['id'], endpoint)
|
||||
|
||||
# create a service, with no name
|
||||
unnamed_svc = {
|
||||
'id': uuid.uuid4().hex,
|
||||
'type': uuid.uuid4().hex
|
||||
}
|
||||
self.catalog_api.create_service(unnamed_svc['id'], unnamed_svc)
|
||||
endpoint = self.new_endpoint_ref(service_id=unnamed_svc['id'])
|
||||
self.catalog_api.create_endpoint(endpoint['id'], endpoint)
|
||||
|
||||
region = None
|
||||
catalog = self.catalog_api.get_catalog(user_id, tenant_id)
|
||||
|
||||
self.assertEqual(named_svc['name'],
|
||||
catalog[region][named_svc['type']]['name'])
|
||||
self.assertEqual('', catalog[region][unnamed_svc['type']]['name'])
|
||||
|
@ -675,6 +675,39 @@ class TestCatalogAPISQL(tests.TestCase):
|
||||
# all three appear in the backend
|
||||
self.assertEqual(3, len(self.catalog_api.list_endpoints()))
|
||||
|
||||
def test_get_catalog_always_returns_service_name(self):
|
||||
user_id = uuid.uuid4().hex
|
||||
tenant_id = uuid.uuid4().hex
|
||||
|
||||
# create a service, with a name
|
||||
named_svc = {
|
||||
'id': uuid.uuid4().hex,
|
||||
'type': uuid.uuid4().hex,
|
||||
'name': uuid.uuid4().hex,
|
||||
}
|
||||
self.catalog_api.create_service(named_svc['id'], named_svc)
|
||||
endpoint = self.new_endpoint_ref(service_id=named_svc['id'])
|
||||
self.catalog_api.create_endpoint(endpoint['id'], endpoint)
|
||||
|
||||
# create a service, with no name
|
||||
unnamed_svc = {
|
||||
'id': uuid.uuid4().hex,
|
||||
'type': uuid.uuid4().hex
|
||||
}
|
||||
self.catalog_api.create_service(unnamed_svc['id'], unnamed_svc)
|
||||
endpoint = self.new_endpoint_ref(service_id=unnamed_svc['id'])
|
||||
self.catalog_api.create_endpoint(endpoint['id'], endpoint)
|
||||
|
||||
catalog = self.catalog_api.get_v3_catalog(user_id, tenant_id)
|
||||
|
||||
named_endpoint = [ep for ep in catalog
|
||||
if ep['type'] == named_svc['type']][0]
|
||||
self.assertEqual(named_svc['name'], named_endpoint['name'])
|
||||
|
||||
unnamed_endpoint = [ep for ep in catalog
|
||||
if ep['type'] == unnamed_svc['type']][0]
|
||||
self.assertEqual('', unnamed_endpoint['name'])
|
||||
|
||||
|
||||
# TODO(dstanek): this needs refactoring with the test above, but we are in a
|
||||
# crunch so that will happen in a future patch.
|
||||
|
Loading…
Reference in New Issue
Block a user