Skip to content

Commit

Permalink
fix race condition test failure (seen on Jython)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed Nov 18, 2010
1 parent 85ee02b commit e57f5c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pyramid/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def b64decode(v):

class AuthTktCookieHelper(object):
auth_tkt = auth_tkt # for tests
now = None # for tests

userid_type_decoders = {
'int':int,
Expand Down Expand Up @@ -373,7 +374,10 @@ def identify(self, request):
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
Expand Down
6 changes: 4 additions & 2 deletions pyramid/tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,10 @@ def test_identify_cookie_timed_out(self):

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)
Expand Down

0 comments on commit e57f5c2

Please sign in to comment.