diff --git a/keystoneclient/access.py b/keystoneclient/access.py index 3947b6f10..c16c22b24 100644 --- a/keystoneclient/access.py +++ b/keystoneclient/access.py @@ -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): @@ -37,7 +37,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? diff --git a/tests/test_access.py b/tests/test_access.py index 621fefc5a..31f91d6ab 100644 --- a/tests/test_access.py +++ b/tests/test_access.py @@ -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'])