From a800fae22c627e89a09ffc35b95dd072416da14a Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 6 Dec 2012 12:31:51 -0800 Subject: [PATCH] Ensure serviceCatalog is list when empty, not dict Fixes bug 1087405. Change-Id: I152c7f418a66ccfe541e26efe75b59bffa6c3849 --- keystone/service.py | 2 +- tests/test_content_types.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/keystone/service.py b/keystone/service.py index 11003b119b..6716760424 100644 --- a/keystone/service.py +++ b/keystone/service.py @@ -892,7 +892,7 @@ class TokenController(wsgi.Application): """ if not catalog_ref: - return {} + return [] services = {} for region, region_ref in catalog_ref.iteritems(): diff --git a/tests/test_content_types.py b/tests/test_content_types.py index 67565207b8..ba0cdef9a5 100644 --- a/tests/test_content_types.py +++ b/tests/test_content_types.py @@ -363,6 +363,22 @@ class CoreApiTests(object): expected_status=200) self.assertValidAuthenticationResponse(r) + def test_authenticate_unscoped(self): + r = self.public_request( + method='POST', + path='/v2.0/tokens', + body={ + 'auth': { + 'passwordCredentials': { + 'username': self.user_foo['name'], + 'password': self.user_foo['password'], + }, + }, + }, + # TODO(dolph): creating a token should result in a 201 Created + expected_status=200) + self.assertValidAuthenticationResponse(r) + def test_get_tenants_for_token(self): r = self.public_request(path='/v2.0/tenants', token=self.get_scoped_token()) @@ -534,7 +550,7 @@ class JsonTestCase(RestfulTestCase, CoreApiTests): if require_service_catalog: self.assertIsNotNone(serviceCatalog) if serviceCatalog is not None: - self.assertTrue(len(r.body['access']['serviceCatalog'])) + self.assertTrue(isinstance(serviceCatalog, list)) for service in r.body['access']['serviceCatalog']: # validate service self.assertIsNotNone(service.get('name')) @@ -797,7 +813,6 @@ class XmlTestCase(RestfulTestCase, CoreApiTests): 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')): # validate service self.assertIsNotNone(service.get('name'))