Skip to content

Commit

Permalink
Fixed #16222: Test failures due to more precise cookie timings. Refs …
Browse files Browse the repository at this point in the history
…[16356].

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16376 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
andrewgodwin committed Jun 11, 2011
1 parent cfd42a3 commit 1a2e385
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion django/contrib/formtools/wizard/tests/cookiestoragetests.py
Expand Up @@ -25,6 +25,7 @@ def test_manipulated_cookie(self):
self.assertRaises(SuspiciousOperation, storage.load_data)

def test_reset_cookie(self):
from django.core.signing import SignatureExpired
request = get_request()
storage = self.get_storage()('wizard1', request, None)

Expand All @@ -35,7 +36,15 @@ def test_reset_cookie(self):

cookie_signer = signing.get_cookie_signer(storage.prefix)
signed_cookie_data = cookie_signer.sign(storage.encoder.encode(storage.data))
self.assertEqual(response.cookies[storage.prefix].value, signed_cookie_data)

# signing with different timestamps generates different signatures
self.assertNotEqual(response.cookies[storage.prefix].value, signed_cookie_data)
self.assertEqual(cookie_signer.unsign(response.cookies[storage.prefix].value),
cookie_signer.unsign(signed_cookie_data))
self.assertRaises(SignatureExpired,
lambda: cookie_signer.unsign(value=response.cookies[storage.prefix].value, max_age=0))
self.assertEqual(cookie_signer.unsign(value=response.cookies[storage.prefix].value, max_age=10),
cookie_signer.unsign(signed_cookie_data))

storage.init_data()
storage.update_response(response)
Expand Down

0 comments on commit 1a2e385

Please sign in to comment.