Changes FakeMemcache to set token to expire on utcnow + 5 mins

fixes bug 1240994

keystoneclient 0.4 will use utcnow to compare expiration date.
The FakMemcache class sets expiration to datetime.now which sets
date for local timezone. If this timezone happens to be behind
utc the test will fail with expiration error because we are
comparing utc + 5 mins with utc - 1 or more hours.

Change-Id: I551506a5aaf0aef77476b11786399a66225603bf
This commit is contained in:
David Peraza 2013-10-16 13:14:10 -05:00
parent c0b7e4984a
commit ac2a503d4d

View File

@ -41,7 +41,7 @@ class FakeMemcache(object):
@staticmethod @staticmethod
def get(key): def get(key):
if key == "tokens/%s" % VALID_TOKEN: if key == "tokens/%s" % VALID_TOKEN:
dt = datetime.datetime.now() + datetime.timedelta(minutes=5) dt = timeutils.utcnow() + datetime.timedelta(minutes=5)
return json.dumps(({'access': { return json.dumps(({'access': {
'token': {'id': VALID_TOKEN}, 'token': {'id': VALID_TOKEN},
'user': { 'user': {
@ -54,7 +54,7 @@ class FakeMemcache(object):
]}, ]},
}}, timeutils.isotime(dt))) }}, timeutils.isotime(dt)))
if key == "tokens/%s" % VALID_TOKEN2: if key == "tokens/%s" % VALID_TOKEN2:
dt = datetime.datetime.now() + datetime.timedelta(minutes=5) dt = timeutils.utcnow() + datetime.timedelta(minutes=5)
return json.dumps(({'access': { return json.dumps(({'access': {
'token': {'id': VALID_TOKEN2}, 'token': {'id': VALID_TOKEN2},
'user': { 'user': {