1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Refs #36390 -- Removed support for RemoteUserMiddleware subclasses missing aprocess_request().

Per deprecation timeline.
This commit is contained in:
Jacob Walls
2025-09-05 14:25:32 -04:00
committed by nessita
parent 7d7e5cd055
commit 0655d958bd
3 changed files with 6 additions and 66 deletions

View File

@@ -13,7 +13,6 @@ from django.test import (
modify_settings,
override_settings,
)
from django.utils.deprecation import RemovedInDjango61Warning
@override_settings(ROOT_URLCONF="auth_tests.urls")
@@ -490,51 +489,3 @@ class PersistentRemoteUserTest(RemoteUserTest):
response = await self.async_client.get("/remote_user/")
self.assertFalse(response.context["user"].is_anonymous)
self.assertEqual(response.context["user"].username, "knownuser")
# RemovedInDjango61Warning.
class CustomProcessRequestMiddlewareSyncOnly(RemoteUserMiddleware):
def process_request(self, request):
raise NotImplementedError("process_request has not been implemented.")
# RemovedInDjango61Warning.
class CustomProcessRequestMiddleware(RemoteUserMiddleware):
def process_request(self, request):
raise NotImplementedError("process_request has not been implemented.")
async def aprocess_request(self, request):
raise NotImplementedError("aprocess_request has not been implemented.")
# RemovedInDjango61Warning.
@override_settings(ROOT_URLCONF="auth_tests.urls")
class CustomProcessRequestMiddlewareTest(TestCase):
@modify_settings(
MIDDLEWARE={
"append": "auth_tests.test_remote_user."
"CustomProcessRequestMiddlewareSyncOnly"
}
)
async def test_async_warns_sync_only_middleware(self):
deprecation_msg = (
"Support for subclasses of RemoteUserMiddleware that override "
"process_request() without overriding aprocess_request() is "
"deprecated."
)
error_msg = "process_request has not been implemented."
with (
self.assertWarnsMessage(RemovedInDjango61Warning, deprecation_msg),
self.assertRaisesMessage(NotImplementedError, error_msg),
):
await self.async_client.get("/remote_user/")
@modify_settings(
MIDDLEWARE={
"append": "auth_tests.test_remote_user.CustomProcessRequestMiddleware"
}
)
async def test_async_no_warning_sync_and_async_middleware(self):
error_msg = "aprocess_request has not been implemented."
with self.assertRaisesMessage(NotImplementedError, error_msg):
await self.async_client.get("/remote_user/")