diff options
| author | Chris McDonough <chrism@plope.com> | 2010-11-18 04:41:50 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2010-11-18 04:41:50 -0500 |
| commit | e57f5c2dd29f6bd88158a4b84ef67694fd33ba47 (patch) | |
| tree | d299b7eda21687076da59e0d4c30d5d2bd4d18ac | |
| parent | 85ee02b24caf0bf6b491b5ecf7ad84c29ca8c75c (diff) | |
| download | pyramid-e57f5c2dd29f6bd88158a4b84ef67694fd33ba47.tar.gz pyramid-e57f5c2dd29f6bd88158a4b84ef67694fd33ba47.tar.bz2 pyramid-e57f5c2dd29f6bd88158a4b84ef67694fd33ba47.zip | |
fix race condition test failure (seen on Jython)
| -rw-r--r-- | pyramid/authentication.py | 6 | ||||
| -rw-r--r-- | pyramid/tests/test_authentication.py | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/pyramid/authentication.py b/pyramid/authentication.py index 4849d2c41..86d725bcf 100644 --- a/pyramid/authentication.py +++ b/pyramid/authentication.py @@ -286,6 +286,7 @@ EXPIRE = object() class AuthTktCookieHelper(object): auth_tkt = auth_tkt # for tests + now = None # for tests userid_type_decoders = { 'int':int, @@ -373,7 +374,10 @@ class AuthTktCookieHelper(object): except self.auth_tkt.BadTicket: return None - now = time.time() + now = self.now # service tests + + if now is None: + now = time.time() if self.timeout and ( (timestamp + self.timeout) < now ): return None diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index 69762fdb0..d9d0c2c97 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -411,8 +411,10 @@ class TestAuthTktCookieHelper(unittest.TestCase): def test_identify_cookie_reissue(self): import time - plugin = self._makeOne('secret', timeout=5000, reissue_time=0) - plugin.auth_tkt.timestamp = time.time() + plugin = self._makeOne('secret', timeout=10, reissue_time=0) + now = time.time() + plugin.auth_tkt.timestamp = now + plugin.now = now + 1 request = self._makeRequest({'HTTP_COOKIE':'auth_tkt=bogus'}) result = plugin.identify(request) self.failUnless(result) |
