From abd2b913d8b352388eb093f0e03b67138db9c490 Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Thu, 14 Nov 2019 10:49:48 +0100 Subject: #915 Test malformed payload for POST commands This patch includes tests for the remaining REST API commands: POST /shell/output POST /session POST /poweroff POST /reboot POST /stop POST /refresh POST /hardware POST /software POST /image/create POST /image/restore POST /setup POST /image/create/basic POST /image/create/incremental POST /image/restore/basic POST /image/restore/incremental POST /run/schedule This test covers requests that are missing one of the parameters in its payload. --- tests/units/test_0012_post_software.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/units/test_0012_post_software.py') diff --git a/tests/units/test_0012_post_software.py b/tests/units/test_0012_post_software.py index 1574683..3a00d46 100644 --- a/tests/units/test_0012_post_software.py +++ b/tests/units/test_0012_post_software.py @@ -18,6 +18,15 @@ class TestPostSoftwareMethods(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