mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed DoS possiblity in contrib.auth.views.logout()
Thanks Florian Apolloner and Carl Meyer for review. This is a security fix.
This commit is contained in:
@@ -678,6 +678,23 @@ class SessionMiddlewareTests(TestCase):
|
||||
str(response.cookies[settings.SESSION_COOKIE_NAME])
|
||||
)
|
||||
|
||||
def test_flush_empty_without_session_cookie_doesnt_set_cookie(self):
|
||||
request = RequestFactory().get('/')
|
||||
response = HttpResponse('Session test')
|
||||
middleware = SessionMiddleware()
|
||||
|
||||
# Simulate a request that ends the session
|
||||
middleware.process_request(request)
|
||||
request.session.flush()
|
||||
|
||||
# Handle the response through the middleware
|
||||
response = middleware.process_response(request, response)
|
||||
|
||||
# A cookie should not be set.
|
||||
self.assertEqual(response.cookies, {})
|
||||
# The session is accessed so "Vary: Cookie" should be set.
|
||||
self.assertEqual(response['Vary'], 'Cookie')
|
||||
|
||||
|
||||
# Don't need DB flushing for these tests, so can use unittest.TestCase as base class
|
||||
class CookieSessionTests(SessionTestsMixin, unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user