summaryrefslogtreecommitdiffstats
path: root/tests/test_v3_catalog.py
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2013-03-13 21:59:38 -0500
committerDolph Mathews <dolph.mathews@gmail.com>2013-03-15 15:00:11 -0500
commit0a81b69ef696264654c37213f4954f222fc78700 (patch)
tree0b18965f87e190d15484adb931dca02be320cf08 /tests/test_v3_catalog.py
parenta79a7c1ddb6c7e3f71cc9791b318bdefbc1abeb8 (diff)
downloadkeystone-0a81b69ef696264654c37213f4954f222fc78700.tar.gz
keystone-0a81b69ef696264654c37213f4954f222fc78700.tar.xz
keystone-0a81b69ef696264654c37213f4954f222fc78700.zip
Discard null endpoints (bug 1152632)
If a v2 client passed {..., "adminurl": null, ...} in a endpoint-create request, then the null value was being persisted on an endpoint with a different interface value (i.e. a publicly facing endpoint would have an "adminurl": null value inexplicably attached to it.) This change simply pops null urls from the endpoint and discards them. Change-Id: Idd0964b6ec34fbc8b979253d32f655ea9797f259
Diffstat (limited to 'tests/test_v3_catalog.py')
-rw-r--r--tests/test_v3_catalog.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_v3_catalog.py b/tests/test_v3_catalog.py
index 67cbd340..e81308fc 100644
--- a/tests/test_v3_catalog.py
+++ b/tests/test_v3_catalog.py
@@ -114,3 +114,52 @@ class CatalogTestCase(test_v3.RestfulTestCase):
self.delete(
'/endpoints/%(endpoint_id)s' % {
'endpoint_id': self.endpoint_id})
+
+ def test_create_endpoint_on_v2(self):
+ # clear the v3 endpoint so we only have endpoints created on v2
+ self.delete(
+ '/endpoints/%(endpoint_id)s' % {
+ 'endpoint_id': self.endpoint_id})
+
+ # create a v3 endpoint ref, and then tweak it back to a v2-style ref
+ ref = self.new_endpoint_ref(service_id=self.service['id'])
+ del ref['id']
+ del ref['interface']
+ ref['publicurl'] = ref.pop('url')
+ ref['internalurl'] = None
+ # don't set adminurl to ensure it's absence is handled like internalurl
+
+ # create the endpoint on v2 (using a v3 token)
+ r = self.admin_request(
+ method='POST',
+ path='/v2.0/endpoints',
+ token=self.get_scoped_token(),
+ body={'endpoint': ref})
+ endpoint_v2 = r.body['endpoint']
+
+ # test the endpoint on v3
+ r = self.get('/endpoints')
+ endpoints = self.assertValidEndpointListResponse(r)
+ self.assertEqual(len(endpoints), 1)
+ endpoint_v3 = endpoints.pop()
+
+ # these attributes are identical between both API's
+ self.assertEqual(endpoint_v3['region'], ref['region'])
+ self.assertEqual(endpoint_v3['service_id'], ref['service_id'])
+ self.assertEqual(endpoint_v3['description'], ref['description'])
+
+ # a v2 endpoint is not quite the same concept as a v3 endpoint, so they
+ # receive different identifiers
+ self.assertNotEqual(endpoint_v2['id'], endpoint_v3['id'])
+
+ # v2 has a publicurl; v3 has a url + interface type
+ self.assertEqual(endpoint_v3['url'], ref['publicurl'])
+ self.assertEqual(endpoint_v3['interface'], 'public')
+
+ # tests for bug 1152632 -- these attributes were being returned by v3
+ self.assertNotIn('publicurl', endpoint_v3)
+ self.assertNotIn('adminurl', endpoint_v3)
+ self.assertNotIn('internalurl', endpoint_v3)
+
+ # test for bug 1152635 -- this attribute was being returned by v3
+ self.assertNotIn('legacy_endpoint_id', endpoint_v3)