summaryrefslogtreecommitdiff
path: root/tests/responses
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2018-04-13 20:58:31 -0400
committerTim Graham <timograham@gmail.com>2018-04-13 20:58:31 -0400
commit9a56b4b13ed92d2d5bb00d6bdb905a73bc5f2f0a (patch)
treeddb311604d1ec31ec09c8ae12e34dadc821f7536 /tests/responses
parent13efbb233a9aa2e3f13be863c6616ec0767a0d58 (diff)
Fixed #27863 -- Added support for the SameSite cookie flag.
Thanks Alex Gaynor for contributing to the patch.
Diffstat (limited to 'tests/responses')
-rw-r--r--tests/responses/test_cookie.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/responses/test_cookie.py b/tests/responses/test_cookie.py
index 148963fa59..a5092c3bbf 100644
--- a/tests/responses/test_cookie.py
+++ b/tests/responses/test_cookie.py
@@ -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):