diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-13 15:08:14 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-13 15:08:14 +0000 |
| commit | a7d73d2c4bb42a70eab2fa299c2d79fa2c8ac10f (patch) | |
| tree | b3e5bdf40452697c8da4cb34da6e410521d20d2f | |
| parent | 1b33ddd74d75048ecba633d0841a051f72da0903 (diff) | |
| parent | ae0515c3a078ce27ccca1ef5a98092208c030f2f (diff) | |
| download | keystone-a7d73d2c4bb42a70eab2fa299c2d79fa2c8ac10f.tar.gz keystone-a7d73d2c4bb42a70eab2fa299c2d79fa2c8ac10f.tar.xz keystone-a7d73d2c4bb42a70eab2fa299c2d79fa2c8ac10f.zip | |
Merge "Admin Auth URI prefix"
| -rw-r--r-- | keystone/config.py | 1 | ||||
| -rw-r--r-- | keystone/middleware/auth_token.py | 4 | ||||
| -rw-r--r-- | tests/test_auth_token_middleware.py | 9 |
3 files changed, 13 insertions, 1 deletions
diff --git a/keystone/config.py b/keystone/config.py index 86c50c82..8529eb8a 100644 --- a/keystone/config.py +++ b/keystone/config.py @@ -117,6 +117,7 @@ register_str('compute_port', default=8774) register_str('admin_port', default=35357) register_str('public_port', default=5000) register_str('onready') +register_str('auth_admin_prefix', default='') #ssl options register_bool('enable', group='ssl', default=False) diff --git a/keystone/middleware/auth_token.py b/keystone/middleware/auth_token.py index 0fa35fde..3c379983 100644 --- a/keystone/middleware/auth_token.py +++ b/keystone/middleware/auth_token.py @@ -139,6 +139,7 @@ class AuthProtocol(object): default_auth_uri = '%s://%s:%s' % (self.auth_protocol, self.auth_host, self.auth_port) + self.auth_admin_prefix = conf.get('auth_admin_prefix', '') self.auth_uri = conf.get('auth_uri', default_auth_uri) # SSL @@ -297,8 +298,9 @@ class AuthProtocol(object): if body: kwargs['body'] = jsonutils.dumps(body) + full_path = self.auth_admin_prefix + path try: - conn.request(method, path, **kwargs) + conn.request(method, full_path, **kwargs) response = conn.getresponse() body = response.read() except Exception, e: diff --git a/tests/test_auth_token_middleware.py b/tests/test_auth_token_middleware.py index 1e71863f..dc5760ca 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 @@ -149,6 +150,8 @@ class FakeHTTPResponse(object): class FakeHTTPConnection(object): + last_requested_url = '' + def __init__(self, *args): pass @@ -163,6 +166,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({ @@ -223,6 +227,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) @@ -262,6 +267,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']) |
