mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #31962 -- Made SessionMiddleware raise SessionInterrupted when session destroyed while request is processing.
This commit is contained in:
parent
fc1446073e
commit
2808cdc8fb
13 changed files with 108 additions and 10 deletions
|
@ -19,7 +19,9 @@ from django.contrib.sessions.backends.file import SessionStore as FileSession
|
|||
from django.contrib.sessions.backends.signed_cookies import (
|
||||
SessionStore as CookieSession,
|
||||
)
|
||||
from django.contrib.sessions.exceptions import InvalidSessionKey
|
||||
from django.contrib.sessions.exceptions import (
|
||||
InvalidSessionKey, SessionInterrupted,
|
||||
)
|
||||
from django.contrib.sessions.middleware import SessionMiddleware
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.contrib.sessions.serializers import (
|
||||
|
@ -28,7 +30,7 @@ from django.contrib.sessions.serializers import (
|
|||
from django.core import management
|
||||
from django.core.cache import caches
|
||||
from django.core.cache.backends.base import InvalidCacheBackendError
|
||||
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http import HttpResponse
|
||||
from django.test import (
|
||||
RequestFactory, SimpleTestCase, TestCase, ignore_warnings,
|
||||
|
@ -746,10 +748,10 @@ class SessionMiddlewareTests(TestCase):
|
|||
"The request's session was deleted before the request completed. "
|
||||
"The user may have logged out in a concurrent request, for example."
|
||||
)
|
||||
with self.assertRaisesMessage(SuspiciousOperation, msg):
|
||||
with self.assertRaisesMessage(SessionInterrupted, msg):
|
||||
# Handle the response through the middleware. It will try to save
|
||||
# the deleted session which will cause an UpdateError that's caught
|
||||
# and raised as a SuspiciousOperation.
|
||||
# and raised as a SessionInterrupted.
|
||||
middleware(request)
|
||||
|
||||
def test_session_delete_on_end(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue