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
aa7e7b96e7
commit
f70505ced1
|
@ -325,7 +325,7 @@ class TokenTests(object):
|
|||
|
||||
def test_expired_token(self):
|
||||
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_ref = self.token_api.create_token(token_id, data)
|
||||
self.assertDictEquals(data_ref, data)
|
||||
|
|
|
@ -42,7 +42,7 @@ class MemcacheClient(object):
|
|||
"""Retrieves the value for a key or None."""
|
||||
self.check_key(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):
|
||||
return obj[0]
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue