mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #30862 -- Allowed setting SameSite cookies flags to 'none'.
Thanks Florian Apolloner and Carlton Gibson for reviews.
This commit is contained in:
committed by
Mariusz Felisiak
parent
14e690ae5a
commit
b33bfc3839
@@ -81,13 +81,16 @@ class SetCookieTests(SimpleTestCase):
|
||||
|
||||
def test_samesite(self):
|
||||
response = HttpResponse()
|
||||
response.set_cookie('example', samesite='None')
|
||||
self.assertEqual(response.cookies['example']['samesite'], 'None')
|
||||
response.set_cookie('example', samesite='Lax')
|
||||
self.assertEqual(response.cookies['example']['samesite'], 'Lax')
|
||||
response.set_cookie('example', samesite='strict')
|
||||
self.assertEqual(response.cookies['example']['samesite'], 'strict')
|
||||
|
||||
def test_invalid_samesite(self):
|
||||
with self.assertRaisesMessage(ValueError, 'samesite must be "lax" or "strict".'):
|
||||
msg = 'samesite must be "lax", "none", or "strict".'
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
HttpResponse().set_cookie('example', samesite='invalid')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user