summaryrefslogtreecommitdiffstats
path: root/tests/test_content_types.py
diff options
context:
space:
mode:
authorMichael Basnight <mbasnight@gmail.com>2012-03-06 21:36:01 -0600
committerMichael Basnight <mbasnight@gmail.com>2012-03-07 15:11:27 -0600
commit98170a73dd28cebf9737c012d03554ffce5fd1f5 (patch)
treee9daa0235e2bea919086cfe67fd988dcce499bf2 /tests/test_content_types.py
parentfe6414c8c1f769e6cc87fc001b6c52c5fea0f160 (diff)
downloadkeystone-98170a73dd28cebf9737c012d03554ffce5fd1f5.tar.gz
keystone-98170a73dd28cebf9737c012d03554ffce5fd1f5.tar.xz
keystone-98170a73dd28cebf9737c012d03554ffce5fd1f5.zip
fixes bug lp#948439 belongs_to and serviceCatalog behavior
* removing belongs_to as a kwarg and getting from the context * adding a serviceCatalog for belongs_to calls to tokens * adding test to validate belongs_to behavior in tokens Change-Id: If6f6a7007a6830c57a5ac71aef0090e57a064232
Diffstat (limited to 'tests/test_content_types.py')
-rw-r--r--tests/test_content_types.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/test_content_types.py b/tests/test_content_types.py
index b98ae773..d98330a4 100644
--- a/tests/test_content_types.py
+++ b/tests/test_content_types.py
@@ -352,6 +352,14 @@ class CoreApiTests(object):
token=token)
self.assertValidAuthenticationResponse(r)
+ def test_validate_token_belongs_to(self):
+ token = self.get_scoped_token()
+ path = ('/v2.0/tokens/%s?belongs_to=%s'
+ % (token, self.tenant_bar['id']))
+ r = self.admin_request(path=path,token=token)
+ self.assertValidAuthenticationResponse(r,
+ require_service_catalog=True)
+
def test_validate_token_head(self):
"""The same call as above, except using HEAD.
@@ -448,7 +456,8 @@ class JsonTestCase(RestfulTestCase, CoreApiTests):
def assertValidExtensionResponse(self, r):
self.assertValidExtension(r.body.get('extension'))
- def assertValidAuthenticationResponse(self, r):
+ def assertValidAuthenticationResponse(self, r,
+ require_service_catalog=False):
self.assertIsNotNone(r.body.get('access'))
self.assertIsNotNone(r.body['access'].get('token'))
self.assertIsNotNone(r.body['access'].get('user'))
@@ -466,8 +475,11 @@ class JsonTestCase(RestfulTestCase, CoreApiTests):
self.assertIsNotNone(r.body['access']['user'].get('id'))
self.assertIsNotNone(r.body['access']['user'].get('name'))
+ serviceCatalog = r.body['access'].get('serviceCatalog')
# validate service catalog
- if r.body['access'].get('serviceCatalog') is not None:
+ if require_service_catalog:
+ self.assertIsNotNone(serviceCatalog)
+ if serviceCatalog is not None:
self.assertTrue(len(r.body['access']['serviceCatalog']))
for service in r.body['access']['serviceCatalog']:
# validate service
@@ -627,7 +639,8 @@ class XmlTestCase(RestfulTestCase, CoreApiTests):
for role in r.body.findall(self._tag('role')):
self.assertValidRole(role)
- def assertValidAuthenticationResponse(self, r):
+ def assertValidAuthenticationResponse(self, r,
+ require_service_catalog=False):
xml = r.body
self.assertEqual(xml.tag, self._tag('access'))
@@ -648,6 +661,9 @@ class XmlTestCase(RestfulTestCase, CoreApiTests):
self.assertIsNotNone(user.get('name'))
serviceCatalog = xml.find(self._tag('serviceCatalog'))
+ # validate the serviceCatalog
+ if require_service_catalog:
+ self.assertIsNotNone(serviceCatalog)
if serviceCatalog is not None:
self.assertTrue(len(serviceCatalog.findall(self._tag('service'))))
for service in serviceCatalog.findall(self._tag('service')):