mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #27863 -- Added support for the SameSite cookie flag.
Thanks Alex Gaynor for contributing to the patch.
This commit is contained in:
@@ -79,6 +79,17 @@ class SetCookieTests(SimpleTestCase):
|
||||
response.set_cookie('test', cookie_value)
|
||||
self.assertEqual(response.cookies['test'].value, cookie_value)
|
||||
|
||||
def test_samesite(self):
|
||||
response = HttpResponse()
|
||||
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".'):
|
||||
HttpResponse().set_cookie('example', samesite='invalid')
|
||||
|
||||
|
||||
class DeleteCookieTests(SimpleTestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user