diff options
author | Luke Plant <L.Plant.98@cantab.net> | 2022-03-04 13:05:07 +0000 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-07 08:04:18 +0100 |
commit | f3bf6c4218404479f7841e0af213d5db65913278 (patch) | |
tree | 9d49a86c58a315ca7ddb8c2082917074a04dceb3 /tests/responses | |
parent | ae2da5ba652c1a11cd88dcb119744dcecaeb03ee (diff) | |
download | django-f3bf6c4218404479f7841e0af213d5db65913278.tar.gz |
Refs #33562 -- Made HttpResponse.set_cookie() raise ValueError when both "expires" and "max_age" are passed.
This fixes the case where you might pass set_cookie(expires=val, max_age=val)
and max_age is silently ignored.
Diffstat (limited to 'tests/responses')
-rw-r--r-- | tests/responses/test_cookie.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/responses/test_cookie.py b/tests/responses/test_cookie.py index 3a57dcfe45..b6610cbaab 100644 --- a/tests/responses/test_cookie.py +++ b/tests/responses/test_cookie.py @@ -76,6 +76,14 @@ class SetCookieTests(SimpleTestCase): response.set_cookie("max_age", max_age=timedelta(hours=1)) self.assertEqual(response.cookies["max_age"]["max-age"], 3600) + def test_max_age_with_expires(self): + response = HttpResponse() + msg = "'expires' and 'max_age' can't be used together." + with self.assertRaisesMessage(ValueError, msg): + response.set_cookie( + "max_age", expires=datetime(2000, 1, 1), max_age=timedelta(hours=1) + ) + def test_httponly_cookie(self): response = HttpResponse() response.set_cookie("example", httponly=True) |