Merge "Cached tokens aren't expired"
This commit is contained in:
@@ -1014,7 +1014,7 @@ class AuthProtocol(object):
|
|||||||
env_key = self._header_to_env_var(key)
|
env_key = self._header_to_env_var(key)
|
||||||
return env.get(env_key, default)
|
return env.get(env_key, default)
|
||||||
|
|
||||||
def _cache_get(self, token_id, ignore_expires=False):
|
def _cache_get(self, token_id):
|
||||||
"""Return token information from cache.
|
"""Return token information from cache.
|
||||||
|
|
||||||
If token is invalid raise InvalidUserToken
|
If token is invalid raise InvalidUserToken
|
||||||
@@ -1077,7 +1077,7 @@ class AuthProtocol(object):
|
|||||||
|
|
||||||
expires = timeutils.normalize_time(expires)
|
expires = timeutils.normalize_time(expires)
|
||||||
utcnow = timeutils.utcnow()
|
utcnow = timeutils.utcnow()
|
||||||
if ignore_expires or utcnow < expires:
|
if utcnow < expires:
|
||||||
self.LOG.debug('Returning cached token')
|
self.LOG.debug('Returning cached token')
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
|
@@ -718,8 +718,7 @@ class CommonAuthTokenMiddlewareTest(object):
|
|||||||
|
|
||||||
def _get_cached_token(self, token):
|
def _get_cached_token(self, token):
|
||||||
token_id = cms.cms_hash_token(token)
|
token_id = cms.cms_hash_token(token)
|
||||||
# NOTE(vish): example tokens are expired so skip the expiration check.
|
return self.middleware._cache_get(token_id)
|
||||||
return self.middleware._cache_get(token_id, ignore_expires=True)
|
|
||||||
|
|
||||||
def test_memcache(self):
|
def test_memcache(self):
|
||||||
# NOTE(jamielennox): it appears that httpretty can mess with the
|
# NOTE(jamielennox): it appears that httpretty can mess with the
|
||||||
|
Reference in New Issue
Block a user