diff options
Diffstat (limited to 'tests/handlers/tests.py')
-rw-r--r-- | tests/handlers/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index f574418ae2..a543513a25 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -93,6 +93,19 @@ class HandlerTests(TestCase): # latest versions. self.assertIsInstance(request.COOKIES, dict) + @override_settings(ROOT_URLCONF='handlers.urls') + def test_invalid_multipart_boundary(self): + """ + Invalid boundary string should produce a "Bad Request" response, not a + server error (#23887). + """ + environ = RequestFactory().post('/malformed_post/').environ + environ['CONTENT_TYPE'] = 'multipart/form-data; boundary=WRONG\x07' + handler = WSGIHandler() + response = handler(environ, lambda *a, **k: None) + # Expect "bad request" response + self.assertEqual(response.status_code, 400) + @override_settings(ROOT_URLCONF='handlers.urls') class TransactionsPerRequestTests(TransactionTestCase): |