Merge "Fix STALE_TOKEN_DURATION usage"
This commit is contained in:
commit
1cbda90717
@ -21,7 +21,7 @@ from keystoneclient.openstack.common import timeutils
|
||||
|
||||
|
||||
# gap, in seconds, to determine whether the given token is about to expire
|
||||
STALE_TOKEN_DURATION = '30'
|
||||
STALE_TOKEN_DURATION = 30
|
||||
|
||||
|
||||
class AccessInfo(dict):
|
||||
@ -34,7 +34,8 @@ class AccessInfo(dict):
|
||||
:return: boolean : true if expiration is within the given duration
|
||||
|
||||
"""
|
||||
stale_duration = stale_duration or TALE_TOKEN_DURATION
|
||||
stale_duration = (STALE_TOKEN_DURATION if stale_duration is None
|
||||
else stale_duration)
|
||||
norm_expires = timeutils.normalize_time(self.expires)
|
||||
# (gyee) should we move auth_token.will_expire_soon() to timeutils
|
||||
# instead of duplicating code here?
|
||||
|
@ -40,6 +40,7 @@ class AccessInfoTest(utils.TestCase):
|
||||
auth_ref = access.AccessInfo(UNSCOPED_TOKEN['access'])
|
||||
self.assertFalse(auth_ref.will_expire_soon(stale_duration=120))
|
||||
self.assertTrue(auth_ref.will_expire_soon(stale_duration=300))
|
||||
self.assertFalse(auth_ref.will_expire_soon())
|
||||
|
||||
def test_building_scoped_accessinfo(self):
|
||||
auth_ref = access.AccessInfo(PROJECT_SCOPED_TOKEN['access'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user