From 1cdbc5facf0055c4996e4da9457299b0280baf58 Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Wed, 13 Nov 2019 13:45:37 +0100 Subject: #915 Test malformed payload for POST /shell/run This test covers requests that do not contain 1 of the parameters in their payloads. --- tests/units/test_0004_post_shell_run.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/units/test_0004_post_shell_run.py b/tests/units/test_0004_post_shell_run.py index 929565c..11779da 100644 --- a/tests/units/test_0004_post_shell_run.py +++ b/tests/units/test_0004_post_shell_run.py @@ -18,6 +18,15 @@ class TestPostShellRunMethods(unittest.TestCase): returned = requests.post(self.url, headers=self.headers, json=None) self.assertEqual(returned.status_code, 400) + def test_malformed_payload(self): + for parameter in self.json: + malformed_payload = self.json.copy() + malformed_payload.pop(parameter) + returned = requests.post(self.url, + headers=self.headers, + json=malformed_payload) + self.assertEqual(returned.status_code, 400) + def test_get(self): returned = requests.get(self.url, headers=self.headers) self.assertEqual(returned.status_code, 405) -- cgit v1.2.3-18-g5258