diff options
| author | amalia <amalia.soucek@gmail.com> | 2017-02-10 09:30:51 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-02-13 16:43:23 -0500 |
| commit | b54fff293846d24b3345a86fea223c93926e0c86 (patch) | |
| tree | df04da252380de77b3329e21e89274c93f45af80 /tests | |
| parent | c0916144502b2b9d75b75ce6b01148aaa3dcaf68 (diff) | |
[1.11.x] Fixed #27820 -- Fixed RequestDataTooBig/TooManyFieldsSent crash.
Backport of 2f10216f84b55920de25422842a66260219e393f from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/handlers/test_exception.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/handlers/test_exception.py b/tests/handlers/test_exception.py new file mode 100644 index 0000000000..7afd4acc6b --- /dev/null +++ b/tests/handlers/test_exception.py @@ -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) |
