mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #25644 -- Fixed reset cookie expiry date bug.
Setting a cookie with the same name as a previously deleted cookie would set its expiry date to 'Thu, 01-Jan-1970 00:00:00 GMT'.
This commit is contained in:
parent
6258e16335
commit
0a19f8d4fc
2 changed files with 14 additions and 0 deletions
|
@ -208,6 +208,18 @@ class RequestsTests(SimpleTestCase):
|
|||
datetime_cookie = response.cookies['datetime']
|
||||
self.assertEqual(datetime_cookie['max-age'], 10)
|
||||
|
||||
def test_create_cookie_after_deleting_cookie(self):
|
||||
"""
|
||||
Setting a cookie after deletion should clear the expiry date.
|
||||
"""
|
||||
response = HttpResponse()
|
||||
response.set_cookie('c', 'old-value')
|
||||
self.assertEqual(response.cookies['c']['expires'], '')
|
||||
response.delete_cookie('c')
|
||||
self.assertEqual(response.cookies['c']['expires'], 'Thu, 01-Jan-1970 00:00:00 GMT')
|
||||
response.set_cookie('c', 'new-value')
|
||||
self.assertEqual(response.cookies['c']['expires'], '')
|
||||
|
||||
def test_far_expiration(self):
|
||||
"Cookie will expire when an distant expiration time is provided"
|
||||
response = HttpResponse()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue