Merge "Make auth_token lazy load the auth_version."
This commit is contained in:
@@ -333,9 +333,7 @@ class AuthProtocol(object):
|
|||||||
http_connect_timeout_cfg = self._conf_get('http_connect_timeout')
|
http_connect_timeout_cfg = self._conf_get('http_connect_timeout')
|
||||||
self.http_connect_timeout = (http_connect_timeout_cfg and
|
self.http_connect_timeout = (http_connect_timeout_cfg and
|
||||||
int(http_connect_timeout_cfg))
|
int(http_connect_timeout_cfg))
|
||||||
|
self.auth_version = None
|
||||||
# Determine the highest api version we can use.
|
|
||||||
self.auth_version = self._choose_api_version()
|
|
||||||
|
|
||||||
def _assert_valid_memcache_protection_config(self):
|
def _assert_valid_memcache_protection_config(self):
|
||||||
if self._memcache_security_strategy:
|
if self._memcache_security_strategy:
|
||||||
@@ -982,6 +980,10 @@ class AuthProtocol(object):
|
|||||||
:raise ServiceError if unable to authenticate token
|
:raise ServiceError if unable to authenticate token
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
# Determine the highest api version we can use.
|
||||||
|
if not self.auth_version:
|
||||||
|
self.auth_version = self._choose_api_version()
|
||||||
|
|
||||||
if self.auth_version == 'v3.0':
|
if self.auth_version == 'v3.0':
|
||||||
headers = {'X-Auth-Token': self.get_admin_token(),
|
headers = {'X-Auth-Token': self.get_admin_token(),
|
||||||
'X-Subject-Token': safe_quote(user_token)}
|
'X-Subject-Token': safe_quote(user_token)}
|
||||||
|
@@ -542,6 +542,13 @@ class v3FakeHTTPConnection(FakeHTTPConnection):
|
|||||||
self.resp = FakeHTTPResponse(status, body)
|
self.resp = FakeHTTPResponse(status, body)
|
||||||
|
|
||||||
|
|
||||||
|
class RaisingHTTPConnection(FakeHTTPConnection):
|
||||||
|
""" An HTTPConnection that always raises."""
|
||||||
|
|
||||||
|
def request(self, method, path, **kwargs):
|
||||||
|
raise AssertionError("HTTP request was called.")
|
||||||
|
|
||||||
|
|
||||||
class FakeApp(object):
|
class FakeApp(object):
|
||||||
"""This represents a WSGI app protected by the auth_token middleware."""
|
"""This represents a WSGI app protected by the auth_token middleware."""
|
||||||
def __init__(self, expected_env=None):
|
def __init__(self, expected_env=None):
|
||||||
@@ -788,6 +795,14 @@ class DiabloAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest):
|
|||||||
|
|
||||||
class AuthTokenMiddlewareTest(test.NoModule, BaseAuthTokenMiddlewareTest):
|
class AuthTokenMiddlewareTest(test.NoModule, BaseAuthTokenMiddlewareTest):
|
||||||
|
|
||||||
|
def test_init_does_not_call_http(self):
|
||||||
|
conf = {
|
||||||
|
'auth_host': 'keystone.example.com',
|
||||||
|
'auth_port': 1234
|
||||||
|
}
|
||||||
|
self.set_fake_http(RaisingHTTPConnection)
|
||||||
|
self.set_middleware(conf=conf, fake_http=RaisingHTTPConnection)
|
||||||
|
|
||||||
def assert_valid_last_url(self, token_id):
|
def assert_valid_last_url(self, token_id):
|
||||||
# Default version (v2) has id in the token, override this
|
# Default version (v2) has id in the token, override this
|
||||||
# method for v3 and other versions
|
# method for v3 and other versions
|
||||||
|
Reference in New Issue
Block a user