summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortermie <github@anarkystic.com>2011-11-02 15:04:01 -0700
committertermie <github@anarkystic.com>2011-11-02 15:04:01 -0700
commit0d4e11c48a9082ccc6c56aee2643c87f28367634 (patch)
treeed34789769966288483c3412b94e96883f2ec518
parent2f2465eafa483c1ce365bef01e56211788c8c29d (diff)
authenticate and tenants working
-rw-r--r--keystonelight/backends/templated.py4
-rw-r--r--keystonelight/test.py21
-rw-r--r--keystonelight/wsgi.py1
-rw-r--r--tests/keystoneclient_compat_master.conf6
-rw-r--r--tests/test_keystoneclient_compat.py15
5 files changed, 40 insertions, 7 deletions
diff --git a/keystonelight/backends/templated.py b/keystonelight/backends/templated.py
index 99e867b1..1a848c73 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 9f28b1df..a710203f 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 5be3170e..4f3c6544 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 f2747673..04975917 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 d0c54c0c..1f73adb2 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'])