mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[3.1.x] Fixed #31790 -- Fixed setting SameSite and Secure cookies flags in HttpResponse.delete_cookie().
Cookies with the "SameSite" flag set to None and without the "secure"
flag will be soon rejected by latest browser versions.
This affects sessions and messages cookies.
Backport of 240cbb63bf from master
			
			
This commit is contained in:
		| @@ -105,6 +105,7 @@ class DeleteCookieTests(SimpleTestCase): | ||||
|         self.assertEqual(cookie['path'], '/') | ||||
|         self.assertEqual(cookie['secure'], '') | ||||
|         self.assertEqual(cookie['domain'], '') | ||||
|         self.assertEqual(cookie['samesite'], '') | ||||
|  | ||||
|     def test_delete_cookie_secure_prefix(self): | ||||
|         """ | ||||
| @@ -118,3 +119,14 @@ class DeleteCookieTests(SimpleTestCase): | ||||
|                 cookie_name = '__%s-c' % prefix | ||||
|                 response.delete_cookie(cookie_name) | ||||
|                 self.assertIs(response.cookies[cookie_name]['secure'], True) | ||||
|  | ||||
|     def test_delete_cookie_secure_samesite_none(self): | ||||
|         # delete_cookie() sets the secure flag if samesite='none'. | ||||
|         response = HttpResponse() | ||||
|         response.delete_cookie('c', samesite='none') | ||||
|         self.assertIs(response.cookies['c']['secure'], True) | ||||
|  | ||||
|     def test_delete_cookie_samesite(self): | ||||
|         response = HttpResponse() | ||||
|         response.delete_cookie('c', samesite='lax') | ||||
|         self.assertEqual(response.cookies['c']['samesite'], 'lax') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user