Navigation Menu

Skip to content

Commit

Permalink
Fix expired token tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markmc committed Apr 23, 2012
1 parent 67ee761 commit 4cd2945
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/test_backend.py
Expand Up @@ -326,7 +326,7 @@ def test_token_crud(self):

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.assertDictEqual(data_ref, data)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_backend_memcache.py
Expand Up @@ -42,7 +42,7 @@ def get(self, key):
"""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:
Expand Down

0 comments on commit 4cd2945

Please sign in to comment.