Fix expired token tests
Fixes bug #983800 The expiration timestamps are expressed in UTC time, so ensure: 1) The timestamp of the token created by the test is UTC time (i.e. utcnow() vs now()) 2) The expiration check in the dummy memcache client properly accounts for UTC (i.e. utctimetuple() vs timetuple()) Change-Id: Ie7356456f79ab5a8070a79771bb7d210b1cedd47
This commit is contained in:
parent
67ee761a9d
commit
4cd2945740
@ -326,7 +326,7 @@ class TokenTests(object):
|
|||||||
|
|
||||||
def test_expired_token(self):
|
def test_expired_token(self):
|
||||||
token_id = uuid.uuid4().hex
|
token_id = uuid.uuid4().hex
|
||||||
expire_time = datetime.datetime.now() - datetime.timedelta(minutes=1)
|
expire_time = datetime.datetime.utcnow() - datetime.timedelta(minutes=1)
|
||||||
data = {'id': token_id, 'a': 'b', 'expires': expire_time}
|
data = {'id': token_id, 'a': 'b', 'expires': expire_time}
|
||||||
data_ref = self.token_api.create_token(token_id, data)
|
data_ref = self.token_api.create_token(token_id, data)
|
||||||
self.assertDictEqual(data_ref, data)
|
self.assertDictEqual(data_ref, data)
|
||||||
|
@ -42,7 +42,7 @@ class MemcacheClient(object):
|
|||||||
"""Retrieves the value for a key or None."""
|
"""Retrieves the value for a key or None."""
|
||||||
self.check_key(key)
|
self.check_key(key)
|
||||||
obj = self.cache.get(key)
|
obj = self.cache.get(key)
|
||||||
now = time.mktime(datetime.datetime.utcnow().timetuple())
|
now = time.mktime(datetime.datetime.utcnow().utctimetuple())
|
||||||
if obj and (obj[1] == 0 or obj[1] > now):
|
if obj and (obj[1] == 0 or obj[1] > now):
|
||||||
return obj[0]
|
return obj[0]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user