Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.11.x] Fixed #27820 -- Fixed RequestDataTooBig/TooManyFieldsSent cr…
…ash. Backport of 2f10216 from master
- Loading branch information
1 parent
c091614
commit b54fff2
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.core.handlers.wsgi import WSGIHandler | ||
from django.test import SimpleTestCase, override_settings | ||
from django.test.client import FakePayload | ||
|
||
|
||
class ExceptionHandlerTests(SimpleTestCase): | ||
|
||
def get_suspicious_environ(self): | ||
payload = FakePayload('a=1&a=2;a=3\r\n') | ||
return { | ||
'REQUEST_METHOD': 'POST', | ||
'CONTENT_TYPE': 'application/x-www-form-urlencoded', | ||
'CONTENT_LENGTH': len(payload), | ||
'wsgi.input': payload, | ||
'SERVER_NAME': 'test', | ||
'SERVER_PORT': '8000', | ||
} | ||
|
||
@override_settings(DATA_UPLOAD_MAX_MEMORY_SIZE=12) | ||
def test_data_upload_max_memory_size_exceeded(self): | ||
response = WSGIHandler()(self.get_suspicious_environ(), lambda *a, **k: None) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
@override_settings(DATA_UPLOAD_MAX_NUMBER_FIELDS=2) | ||
def test_data_upload_max_number_fields_exceeded(self): | ||
response = WSGIHandler()(self.get_suspicious_environ(), lambda *a, **k: None) | ||
self.assertEqual(response.status_code, 400) |