1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34742 -- Made CommonMiddleware raise APPEND_SLASH RuntimeError on DELETE requests.

This commit is contained in:
Avaneesh Kumar
2023-12-07 02:54:52 -06:00
committed by Mariusz Felisiak
parent 5b3b791e90
commit 705b1702bd
2 changed files with 8 additions and 5 deletions

View File

@@ -107,11 +107,11 @@ class CommonMiddlewareTest(SimpleTestCase):
self.assertEqual(resp.url, "/slash/?test=slash/")
@override_settings(APPEND_SLASH=True, DEBUG=True)
def test_append_slash_no_redirect_on_POST_in_DEBUG(self):
def test_append_slash_no_redirect_in_DEBUG(self):
"""
While in debug mode, an exception is raised with a warning
when a failed attempt is made to POST, PUT, or PATCH to an URL which
would normally be redirected to a slashed version.
when a failed attempt is made to DELETE, POST, PUT, or PATCH to an URL
which would normally be redirected to a slashed version.
"""
msg = "maintaining %s data. Change your form to point to testserver/slash/"
request = self.rf.get("/slash")
@@ -126,6 +126,9 @@ class CommonMiddlewareTest(SimpleTestCase):
request.method = "PATCH"
with self.assertRaisesMessage(RuntimeError, msg % request.method):
CommonMiddleware(get_response_404)(request)
request = self.rf.delete("/slash")
with self.assertRaisesMessage(RuntimeError, msg % request.method):
CommonMiddleware(get_response_404)(request)
@override_settings(APPEND_SLASH=False)
def test_append_slash_disabled(self):