From 203cf3accd0bec0cc08eab8e736f26cd0e711d8b Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Thu, 12 Nov 2015 22:15:51 -0700 Subject: Add AuthTkt test to test ticket timeouts Previous tests did not actually test the code, other than by chance, which meant future changes could regress, which is bad. --- pyramid/tests/test_authentication.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index 4a6525af2..0a22e5965 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -769,6 +769,17 @@ class TestAuthTktCookieHelper(unittest.TestCase): helper = self._makeOne('secret', timeout='1') self.assertEqual(helper.timeout, 1) + def test_identify_cookie_timeout_aged(self): + import time + helper = self._makeOne('secret', timeout=10) + now = time.time() + helper.auth_tkt.timestamp = now - 1 + helper.now = now + 10 + helper.auth_tkt.tokens = (text_('a'), ) + request = self._makeRequest('bogus') + result = helper.identify(request) + self.assertFalse(result) + def test_identify_cookie_reissue(self): import time helper = self._makeOne('secret', timeout=10, reissue_time=0) -- cgit v1.2.3