mirror of https://github.com/django/django.git
Refs #33562 -- Added tests HttpRequest.get_signed_cookie() with timedeltas.
This commit is contained in:
parent
c6b4d62fa2
commit
1882f6567d
|
@ -1,3 +1,5 @@
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from django.core import signing
|
from django.core import signing
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import SimpleTestCase, override_settings
|
||||||
|
@ -52,8 +54,13 @@ class SignedCookieTest(SimpleTestCase):
|
||||||
with freeze_time(123456800):
|
with freeze_time(123456800):
|
||||||
self.assertEqual(request.get_signed_cookie("c", max_age=12), value)
|
self.assertEqual(request.get_signed_cookie("c", max_age=12), value)
|
||||||
self.assertEqual(request.get_signed_cookie("c", max_age=11), value)
|
self.assertEqual(request.get_signed_cookie("c", max_age=11), value)
|
||||||
|
self.assertEqual(
|
||||||
|
request.get_signed_cookie("c", max_age=timedelta(seconds=11)), value
|
||||||
|
)
|
||||||
with self.assertRaises(signing.SignatureExpired):
|
with self.assertRaises(signing.SignatureExpired):
|
||||||
request.get_signed_cookie("c", max_age=10)
|
request.get_signed_cookie("c", max_age=10)
|
||||||
|
with self.assertRaises(signing.SignatureExpired):
|
||||||
|
request.get_signed_cookie("c", max_age=timedelta(seconds=10))
|
||||||
|
|
||||||
@override_settings(SECRET_KEY=b"\xe7")
|
@override_settings(SECRET_KEY=b"\xe7")
|
||||||
def test_signed_cookies_with_binary_key(self):
|
def test_signed_cookies_with_binary_key(self):
|
||||||
|
|
Loading…
Reference in New Issue