summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2019-11-14 10:49:48 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-11-14 14:51:13 +0100
commitabd2b913d8b352388eb093f0e03b67138db9c490 (patch)
treef04b45e644dd1856382b5758d601d143fa77a81e /tests
parent1cdbc5facf0055c4996e4da9457299b0280baf58 (diff)
#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.
Diffstat (limited to 'tests')
-rw-r--r--tests/units/test_0005_post_shell_output.py4
-rw-r--r--tests/units/test_0006_post_session.py9
-rw-r--r--tests/units/test_0007_post_poweroff.py4
-rw-r--r--tests/units/test_0008_post_reboot.py4
-rw-r--r--tests/units/test_0009_post_stop.py4
-rw-r--r--tests/units/test_0010_post_refresh.py4
-rw-r--r--tests/units/test_0011_post_hardware.py4
-rw-r--r--tests/units/test_0012_post_software.py9
-rw-r--r--tests/units/test_0016_post_image_create.py9
-rw-r--r--tests/units/test_0017_post_image_restore.py9
-rw-r--r--tests/units/test_0018_post_setup.py9
-rw-r--r--tests/units/test_0019_post_image_create_basic.py9
-rw-r--r--tests/units/test_0020_post_image_create_incremental.py9
-rw-r--r--tests/units/test_0021_post_image_restore_basic.py9
-rw-r--r--tests/units/test_0022_post_image_restore_incremental.py9
-rw-r--r--tests/units/test_0023_post_run_schedule.py4
16 files changed, 109 insertions, 0 deletions
diff --git a/tests/units/test_0005_post_shell_output.py b/tests/units/test_0005_post_shell_output.py
index ea44ab6..dec9ccd 100644
--- a/tests/units/test_0005_post_shell_output.py
+++ b/tests/units/test_0005_post_shell_output.py
@@ -16,6 +16,10 @@ class TestPostShellOutputMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)
diff --git a/tests/units/test_0006_post_session.py b/tests/units/test_0006_post_session.py
index 95e181a..ba6179f 100644
--- a/tests/units/test_0006_post_session.py
+++ b/tests/units/test_0006_post_session.py
@@ -17,6 +17,15 @@ class TestPostSessionMethods(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)
diff --git a/tests/units/test_0007_post_poweroff.py b/tests/units/test_0007_post_poweroff.py
index bbf9bf9..3c26265 100644
--- a/tests/units/test_0007_post_poweroff.py
+++ b/tests/units/test_0007_post_poweroff.py
@@ -16,6 +16,10 @@ class TestPostPoweroffMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)
diff --git a/tests/units/test_0008_post_reboot.py b/tests/units/test_0008_post_reboot.py
index 5d4ae06..6705e87 100644
--- a/tests/units/test_0008_post_reboot.py
+++ b/tests/units/test_0008_post_reboot.py
@@ -16,6 +16,10 @@ class TestPostRebootMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)
diff --git a/tests/units/test_0009_post_stop.py b/tests/units/test_0009_post_stop.py
index 4f6e2bf..68b1b7c 100644
--- a/tests/units/test_0009_post_stop.py
+++ b/tests/units/test_0009_post_stop.py
@@ -16,6 +16,10 @@ class TestPostStopMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)
diff --git a/tests/units/test_0010_post_refresh.py b/tests/units/test_0010_post_refresh.py
index 5d4dc81..0df3c60 100644
--- a/tests/units/test_0010_post_refresh.py
+++ b/tests/units/test_0010_post_refresh.py
@@ -16,6 +16,10 @@ class TestPostRefreshMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)
diff --git a/tests/units/test_0011_post_hardware.py b/tests/units/test_0011_post_hardware.py
index 1a620d1..1f3e160 100644
--- a/tests/units/test_0011_post_hardware.py
+++ b/tests/units/test_0011_post_hardware.py
@@ -16,6 +16,10 @@ class TestPostHardwareMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)
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)
diff --git a/tests/units/test_0016_post_image_create.py b/tests/units/test_0016_post_image_create.py
index b3bf3b6..fb6eb97 100644
--- a/tests/units/test_0016_post_image_create.py
+++ b/tests/units/test_0016_post_image_create.py
@@ -22,6 +22,15 @@ class TestPostCreateImageMethods(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)
diff --git a/tests/units/test_0017_post_image_restore.py b/tests/units/test_0017_post_image_restore.py
index ad6ec70..1bdeacb 100644
--- a/tests/units/test_0017_post_image_restore.py
+++ b/tests/units/test_0017_post_image_restore.py
@@ -23,6 +23,15 @@ class TestPostRestoreImageMethods(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)
diff --git a/tests/units/test_0018_post_setup.py b/tests/units/test_0018_post_setup.py
index 9d26b85..16fc1d4 100644
--- a/tests/units/test_0018_post_setup.py
+++ b/tests/units/test_0018_post_setup.py
@@ -39,6 +39,15 @@ class TestPostSetupMethods(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)
diff --git a/tests/units/test_0019_post_image_create_basic.py b/tests/units/test_0019_post_image_create_basic.py
index 5e23254..9d05b99 100644
--- a/tests/units/test_0019_post_image_create_basic.py
+++ b/tests/units/test_0019_post_image_create_basic.py
@@ -30,6 +30,15 @@ class TestPostCreateBasicImageMethods(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)
diff --git a/tests/units/test_0020_post_image_create_incremental.py b/tests/units/test_0020_post_image_create_incremental.py
index bf17979..c677e27 100644
--- a/tests/units/test_0020_post_image_create_incremental.py
+++ b/tests/units/test_0020_post_image_create_incremental.py
@@ -32,6 +32,15 @@ class TestPostCreateIncrementalImageMethods(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)
diff --git a/tests/units/test_0021_post_image_restore_basic.py b/tests/units/test_0021_post_image_restore_basic.py
index b75a068..efe8a61 100644
--- a/tests/units/test_0021_post_image_restore_basic.py
+++ b/tests/units/test_0021_post_image_restore_basic.py
@@ -33,6 +33,15 @@ class TestPostRestoreBasicImageMethods(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)
diff --git a/tests/units/test_0022_post_image_restore_incremental.py b/tests/units/test_0022_post_image_restore_incremental.py
index 1d4c3ba..ad7727f 100644
--- a/tests/units/test_0022_post_image_restore_incremental.py
+++ b/tests/units/test_0022_post_image_restore_incremental.py
@@ -35,6 +35,15 @@ class TestPostRestoreIncrementalImageMethods(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)
diff --git a/tests/units/test_0023_post_run_schedule.py b/tests/units/test_0023_post_run_schedule.py
index 0a0c22f..3b92304 100644
--- a/tests/units/test_0023_post_run_schedule.py
+++ b/tests/units/test_0023_post_run_schedule.py
@@ -16,6 +16,10 @@ class TestPostRunScheduleMethods(unittest.TestCase):
returned = requests.post(self.url, headers=self.headers, json=None)
self.assertEqual(returned.status_code, 400)
+ def test_malformed_payload(self):
+ returned = requests.post(self.url, headers=self.headers, json={})
+ self.assertEqual(returned.status_code, 400)
+
def test_get(self):
returned = requests.get(self.url, headers=self.headers)
self.assertEqual(returned.status_code, 405)