diff --git a/keystonelight/backends/templated.py b/keystonelight/backends/templated.py index 99e867b1df..1a848c73a6 100644 --- a/keystonelight/backends/templated.py +++ b/keystonelight/backends/templated.py @@ -1,3 +1,6 @@ +from keystonelight import logging + + class TemplatedCatalog(object): """A backend that generates endpoints for the Catalog based on templates. @@ -29,6 +32,7 @@ class TemplatedCatalog(object): def __init__(self, options, templates=None): self.options = options + logging.debug('CATALOG PUBLIC PORT BEFORE: %s', options['public_port']) if templates: self.templates = templates diff --git a/keystonelight/test.py b/keystonelight/test.py index 9f28b1df31..a710203f11 100644 --- a/keystonelight/test.py +++ b/keystonelight/test.py @@ -5,6 +5,7 @@ import sys from paste import deploy +from keystonelight import logging from keystonelight import utils from keystonelight import wsgi @@ -67,6 +68,7 @@ class TestCase(unittest.TestCase): def __init__(self, *args, **kw): super(TestCase, self).__init__(*args, **kw) self._paths = [] + self._memo = {} def setUp(self): super(TestCase, self).setUp() @@ -93,11 +95,26 @@ class TestCase(unittest.TestCase): server.start(app, 0, key='socket') # Service catalog tests need to know the port we ran on. - options = self.appconfig(config) port = server.socket_info['socket'][1] - options['public_port'] = port + self._update_server_options(server, 'public_port', port) + logging.debug('PUBLIC PORT: %s', app.options['public_port']) return server + def _update_server_options(self, server, key, value): + """Hack to allow us to make changes to the options used by backends. + + A possible better solution would be to have a global config registry. + + """ + last = server + while hasattr(last, 'application') or hasattr(last, 'options'): + logging.debug('UPDATE %s', last.__class__) + if hasattr(last, 'options'): + last.options[key] = value + if not hasattr(last, 'application'): + break + last = last.application + def client(self, app, *args, **kw): return TestClient(app, *args, **kw) diff --git a/keystonelight/wsgi.py b/keystonelight/wsgi.py index 5be3170e98..4f3c654417 100644 --- a/keystonelight/wsgi.py +++ b/keystonelight/wsgi.py @@ -58,6 +58,7 @@ class Server(object): def start(self, application, port, host='0.0.0.0', key=None, backlog=128): """Run a WSGI server with the given application.""" + self.application = application arg0 = sys.argv[0] logging.debug('Starting %(arg0)s on %(host)s:%(port)s' % locals()) socket = eventlet.listen((host, port), backlog=backlog) diff --git a/tests/keystoneclient_compat_master.conf b/tests/keystoneclient_compat_master.conf index f274767313..049759171a 100644 --- a/tests/keystoneclient_compat_master.conf +++ b/tests/keystoneclient_compat_master.conf @@ -6,9 +6,9 @@ public_port = 5000 # config for TemplatedCatalog, using camelCase because I don't want to do # translations for keystone compat -catalog.RegionOne.identity.publicURL = http://localhost:$(public_port)s/v2.0/$(tenant_id)s -catalog.RegionOne.identity.adminURL = http://localhost:$(public_port)s/v2.0/$(tenant_id)s -catalog.RegionOne.identity.internalURL = http://localhost:$(public_port)s/v2.0/$(tenant_id)s +catalog.RegionOne.identity.publicURL = http://localhost:$(public_port)s/v2.0 +catalog.RegionOne.identity.adminURL = http://localhost:$(public_port)s/v2.0 +catalog.RegionOne.identity.internalURL = http://localhost:$(public_port)s/v2.0 catalog.RegionOne.identity.name = 'Identity Service' diff --git a/tests/test_keystoneclient_compat.py b/tests/test_keystoneclient_compat.py index d0c54c0c0e..1f73adb2fc 100644 --- a/tests/test_keystoneclient_compat.py +++ b/tests/test_keystoneclient_compat.py @@ -55,14 +55,25 @@ class MasterCompatTestCase(CompatTestCase): dict(roles=[], roles_links=[])) + #def test_authenticate(self): + # from keystoneclient.v2_0 import client as ks_client - def test_authenticate(self): + # port = self.server.socket_info['socket'][1] + # client = ks_client.Client(auth_url="http://localhost:%s/v2.0" % port, + # username='foo', + # password='foo', + # project_id='bar') + # client.authenticate() + + def test_authenticate_and_tenants(self): from keystoneclient.v2_0 import client as ks_client port = self.server.socket_info['socket'][1] + self.options['public_port'] = port client = ks_client.Client(auth_url="http://localhost:%s/v2.0" % port, username='foo', password='foo', project_id='bar') client.authenticate() - pass + tenants = client.tenants.list() + self.assertEquals(tenants[0].id, self.tenant_bar['id'])