From 1882f6567df361f52e53b555b2faa677361e128a Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Mon, 7 Mar 2022 07:24:59 +0100 Subject: [PATCH] Refs #33562 -- Added tests HttpRequest.get_signed_cookie() with timedeltas. --- tests/signed_cookies_tests/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/signed_cookies_tests/tests.py b/tests/signed_cookies_tests/tests.py index cca30bb0051..a7ad0c0d840 100644 --- a/tests/signed_cookies_tests/tests.py +++ b/tests/signed_cookies_tests/tests.py @@ -1,3 +1,5 @@ +from datetime import timedelta + from django.core import signing from django.http import HttpRequest, HttpResponse from django.test import SimpleTestCase, override_settings @@ -52,8 +54,13 @@ class SignedCookieTest(SimpleTestCase): with freeze_time(123456800): 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=timedelta(seconds=11)), value + ) with self.assertRaises(signing.SignatureExpired): 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") def test_signed_cookies_with_binary_key(self):