From ae0515c3a078ce27ccca1ef5a98092208c030f2f Mon Sep 17 00:00:00 2001 From: ayoung Date: Sat, 5 May 2012 14:08:18 -0400 Subject: Admin Auth URI prefix Allows the prepending of a prefix to the URI used for admin tasks. This allows URIs like https://hostname/keystone/main/v2.0 PEP8 fix Added To Unit test to ensure auth_prefix is checked Bug: 994860 Change-Id: I851e059e8b17c1bc02ab93d8b09a3fb47b9d3fee --- tests/test_auth_token_middleware.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/test_auth_token_middleware.py b/tests/test_auth_token_middleware.py index 89e9a47c..01736e7c 100644 --- a/tests/test_auth_token_middleware.py +++ b/tests/test_auth_token_middleware.py @@ -20,6 +20,7 @@ import webob from keystone.middleware import auth_token from keystone.openstack.common import jsonutils +from keystone import config from keystone import test @@ -130,6 +131,8 @@ class FakeHTTPResponse(object): class FakeHTTPConnection(object): + last_requested_url = '' + def __init__(self, *args): pass @@ -144,6 +147,7 @@ class FakeHTTPConnection(object): a 404, indicating an unknown (therefore unauthorized) token. """ + FakeHTTPConnection.last_requested_url = path if method == 'POST': status = 200 body = jsonutils.dumps({ @@ -204,6 +208,7 @@ class BaseAuthTokenMiddlewareTest(test.TestCase): 'admin_token': 'admin_token1', 'auth_host': 'keystone.example.com', 'auth_port': 1234, + 'auth_admin_prefix': '/testadmin', } self.middleware = auth_token.AuthProtocol(FakeApp(expected_env), conf) @@ -243,6 +248,10 @@ class AuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest): req = webob.Request.blank('/') req.headers['X-Auth-Token'] = 'valid-token' body = self.middleware(req.environ, self.start_fake_response) + self.assertEqual(self.middleware.conf['auth_admin_prefix'], + "/testadmin") + self.assertEqual("/testadmin/v2.0/tokens/valid-token", + FakeHTTPConnection.last_requested_url) self.assertEqual(self.response_status, 200) self.assertTrue(req.headers.get('X-Service-Catalog')) self.assertEqual(body, ['SUCCESS']) -- cgit