Missing 'region' in service and 'name' in endpoint for EndpointFilterCatalog

EndpointFilterCatalog should return a catalog consistent with the normal
v3 catalog. This means that a service will return the 'region' property
(same as 'region_id') for backwards compatibility. In addition each
endpoint will return its name.

Change-Id: I0f1a337dae1ee2f910d34c14624854a3c9f06358
Closes-Bug: 1532768
This commit is contained in:
Einar Forselv 2016-01-11 13:07:28 +01:00 committed by Steve Martinelli
parent d446a4e297
commit f767b641e8
2 changed files with 12 additions and 0 deletions

View File

@ -50,6 +50,8 @@ class EndpointFilterCatalog(sql.Catalog):
del endpoint['service_id']
del endpoint['enabled']
del endpoint['legacy_endpoint_id']
# Include deprecated region for backwards compatibility
endpoint['region'] = endpoint['region_id']
endpoint['url'] = catalog_core.format_url(
endpoint['url'], substitutions)
# populate filtered endpoints
@ -64,6 +66,7 @@ class EndpointFilterCatalog(sql.Catalog):
formatted_service = {}
formatted_service['id'] = service['id']
formatted_service['type'] = service['type']
formatted_service['name'] = service['name']
formatted_service['endpoints'] = service['endpoints']
catalog.append(formatted_service)

View File

@ -448,6 +448,15 @@ class EndpointFilterTokenRequestTestCase(EndpointFilterTestCase):
self.assertEqual(self.project['id'],
r.result['token']['project']['id'])
# Ensure name of the service exists
self.assertIn('name', r.result['token']['catalog'][0])
# region and region_id should be the same in endpoints
endpoint = r.result['token']['catalog'][0]['endpoints'][0]
self.assertIn('region', endpoint)
self.assertIn('region_id', endpoint)
self.assertEqual(endpoint['region'], endpoint['region_id'])
def test_scoped_token_with_no_catalog_using_endpoint_filter(self):
"""Verify endpoint filter does not affect no catalog."""
self.put('/OS-EP-FILTER/projects/%(project_id)s'