Last change
on this file since 4d98bdf was
784495f,
checked in by OpenGnSys Support Team <soporte-og@…>, 6 years ago
|
#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.
|
-
Property mode set to
100644
|
File size:
492 bytes
|
Rev | Line | |
---|
[784495f] | 1 | import requests |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | MAX_REQ_SIZE = 4096 |
---|
| 5 | |
---|
| 6 | class TestBigRequest(unittest.TestCase): |
---|
| 7 | |
---|
| 8 | def setUp(self): |
---|
| 9 | self.url = 'http://localhost:8888/clients' |
---|
| 10 | self.data = 'X' * MAX_REQ_SIZE |
---|
| 11 | |
---|
| 12 | def test_post(self): |
---|
| 13 | with self.assertRaises(requests.exceptions.ConnectionError) as context: |
---|
| 14 | requests.post(self.url, data=self.data) |
---|
| 15 | |
---|
| 16 | self.assertTrue('Connection reset by peer' in str(context.exception)) |
---|
| 17 | |
---|
| 18 | if __name__ == '__main__': |
---|
| 19 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.