summaryrefslogtreecommitdiffstats
path: root/admin
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
commit666dd3f44c3e59b00b829abaad441c939a5d9710 (patch)
treed6b56007f87a4efb167597b70f07f11f5f48c725 /admin
parentb45357db9c081109c4f2352194979535065aac21 (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 'admin')
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0005_post_shell_output.py4
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0006_post_session.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0007_post_poweroff.py4
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0008_post_reboot.py4
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0009_post_stop.py4
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0010_post_refresh.py4
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0011_post_hardware.py4
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0012_post_software.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0016_post_image_create.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0017_post_image_restore.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0018_post_setup.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0019_post_image_create_basic.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0020_post_image_create_incremental.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0021_post_image_restore_basic.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0022_post_image_restore_incremental.py9
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0023_post_run_schedule.py4
16 files changed, 109 insertions, 0 deletions
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0005_post_shell_output.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0005_post_shell_output.py
index ea44ab6b..dec9ccd0 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0005_post_shell_output.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0006_post_session.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0006_post_session.py
index 95e181a5..ba6179f2 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0006_post_session.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0007_post_poweroff.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0007_post_poweroff.py
index bbf9bf96..3c262656 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0007_post_poweroff.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0008_post_reboot.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0008_post_reboot.py
index 5d4ae061..6705e87f 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0008_post_reboot.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0009_post_stop.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0009_post_stop.py
index 4f6e2bf7..68b1b7c6 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0009_post_stop.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0010_post_refresh.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0010_post_refresh.py
index 5d4dc811..0df3c60f 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0010_post_refresh.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0011_post_hardware.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0011_post_hardware.py
index 1a620d19..1f3e1604 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0011_post_hardware.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0012_post_software.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0012_post_software.py
index 15746836..3a00d467 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0012_post_software.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0016_post_image_create.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0016_post_image_create.py
index b3bf3b65..fb6eb975 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0016_post_image_create.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0017_post_image_restore.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0017_post_image_restore.py
index ad6ec701..1bdeacb5 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0017_post_image_restore.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0018_post_setup.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0018_post_setup.py
index 9d26b85b..16fc1d4e 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0018_post_setup.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0019_post_image_create_basic.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0019_post_image_create_basic.py
index 5e232541..9d05b99d 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0019_post_image_create_basic.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0020_post_image_create_incremental.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0020_post_image_create_incremental.py
index bf179791..c677e270 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0020_post_image_create_incremental.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0021_post_image_restore_basic.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0021_post_image_restore_basic.py
index b75a0682..efe8a61c 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0021_post_image_restore_basic.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0022_post_image_restore_incremental.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0022_post_image_restore_incremental.py
index 1d4c3ba1..ad7727f1 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0022_post_image_restore_incremental.py
+++ b/admin/Sources/Services/ogAdmServer/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/admin/Sources/Services/ogAdmServer/tests/units/test_0023_post_run_schedule.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0023_post_run_schedule.py
index 0a0c22f9..3b923049 100644
--- a/admin/Sources/Services/ogAdmServer/tests/units/test_0023_post_run_schedule.py
+++ b/admin/Sources/Services/ogAdmServer/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)