From 784495f5d504bf88e414e973d5aafc4dada3873b Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Wed, 4 Sep 2019 16:04:19 +0200 Subject: #915 adds test for too large HTTP request This test checks for too large HTTP requests, for example: POST /clients with a body of 4096 bytes. --- tests/units/test_0014_big_request.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/units/test_0014_big_request.py (limited to 'tests/units') diff --git a/tests/units/test_0014_big_request.py b/tests/units/test_0014_big_request.py new file mode 100644 index 0000000..5e5e2d7 --- /dev/null +++ b/tests/units/test_0014_big_request.py @@ -0,0 +1,19 @@ +import requests +import unittest + +MAX_REQ_SIZE = 4096 + +class TestBigRequest(unittest.TestCase): + + def setUp(self): + self.url = 'http://localhost:8888/clients' + self.data = 'X' * MAX_REQ_SIZE + + def test_post(self): + with self.assertRaises(requests.exceptions.ConnectionError) as context: + requests.post(self.url, data=self.data) + + self.assertTrue('Connection reset by peer' in str(context.exception)) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3-18-g5258