diff options
| author | Jamie Lennox <jamielennox@redhat.com> | 2014-03-05 15:19:57 +1000 |
|---|---|---|
| committer | Jamie Lennox <jamielennox@redhat.com> | 2014-04-10 07:05:13 +1000 |
| commit | 00c05a18fa1ce224020b4d3f84f7eba002c9f091 (patch) | |
| tree | 7f0278c36d0f05382ba8b46678e49f460937dc79 /keystoneclient/tests/v3 | |
| parent | ebfaf10357a0ff5f635e9ff9092adae1338f7415 (diff) | |
| download | python-keystoneclient-00c05a18fa1ce224020b4d3f84f7eba002c9f091.tar.gz | |
Add service name to catalog
The service catalog can contain names for the services. These names can
be filtered on by other clients and are going to be required if we
expect to use the keystoneclient service catalog in other clients.
Change-Id: Iab69d67427ed40ce2f556f9a6348f4f1d9c26b5b
Diffstat (limited to 'keystoneclient/tests/v3')
| -rw-r--r-- | keystoneclient/tests/v3/client_fixtures.py | 9 | ||||
| -rw-r--r-- | keystoneclient/tests/v3/test_service_catalog.py | 48 |
2 files changed, 54 insertions, 3 deletions
diff --git a/keystoneclient/tests/v3/client_fixtures.py b/keystoneclient/tests/v3/client_fixtures.py index 32958b4..87361c8 100644 --- a/keystoneclient/tests/v3/client_fixtures.py +++ b/keystoneclient/tests/v3/client_fixtures.py @@ -332,7 +332,8 @@ AUTH_RESPONSE_BODY = { 'region': 'North', 'interface': 'admin' }], - 'type': 'compute' + 'type': 'compute', + 'name': 'nova', }, { 'endpoints': [{ 'url': 'http://swift.north.host/swiftapi/public', @@ -347,7 +348,8 @@ AUTH_RESPONSE_BODY = { 'region': 'South', 'interface': 'admin' }], - 'type': 'object-store' + 'type': 'object-store', + 'name': 'swift', }, { 'endpoints': [{ 'url': 'http://glance.north.host/glanceapi/public', @@ -374,7 +376,8 @@ AUTH_RESPONSE_BODY = { 'region': 'South', 'interface': 'admin' }], - 'type': 'image' + 'type': 'image', + 'name': 'glance', }] } } diff --git a/keystoneclient/tests/v3/test_service_catalog.py b/keystoneclient/tests/v3/test_service_catalog.py index 504cbba..5ad303c 100644 --- a/keystoneclient/tests/v3/test_service_catalog.py +++ b/keystoneclient/tests/v3/test_service_catalog.py @@ -171,3 +171,51 @@ class ServiceCatalogTest(utils.TestCase): for endpoint in endpoints['image']: self.assertEqual(endpoint['url'], self.south_endpoints[endpoint['interface']]) + + def test_service_catalog_service_name(self): + auth_ref = access.AccessInfo.factory(resp=None, + body=self.AUTH_RESPONSE_BODY) + sc = auth_ref.service_catalog + + url = sc.url_for(service_name='glance', endpoint_type='public', + service_type='image', region_name='North') + self.assertEqual('http://glance.north.host/glanceapi/public', url) + + url = sc.url_for(service_name='glance', endpoint_type='public', + service_type='image', region_name='South') + self.assertEqual('http://glance.south.host/glanceapi/public', url) + + self.assertRaises(exceptions.EndpointNotFound, sc.url_for, + service_name='glance', service_type='compute') + + urls = sc.get_urls(service_type='image', service_name='glance', + endpoint_type='public') + + self.assertIn('http://glance.north.host/glanceapi/public', urls) + self.assertIn('http://glance.south.host/glanceapi/public', urls) + + urls = sc.get_urls(service_type='image', service_name='Servers', + endpoint_type='public') + + self.assertIsNone(urls) + + def test_service_catalog_without_name(self): + pr_auth_ref = access.AccessInfo.factory( + resp=None, + body=client_fixtures.PROJECT_SCOPED_TOKEN) + pr_sc = pr_auth_ref.service_catalog + + # this will work because there are no service names on that token + url_ref = 'http://public.com:8774/v2/225da22d3ce34b15877ea70b2a575f58' + url = pr_sc.url_for(service_type='compute', service_name='NotExist', + endpoint_type='public') + self.assertEqual(url_ref, url) + + ab_auth_ref = access.AccessInfo.factory(resp=None, + body=self.AUTH_RESPONSE_BODY) + ab_sc = ab_auth_ref.service_catalog + + # this won't work because there is a name and it's not this one + self.assertRaises(exceptions.EndpointNotFound, ab_sc.url_for, + service_type='compute', service_name='NotExist', + endpoint_type='public') |
