summaryrefslogtreecommitdiffstats
path: root/admin/Sources/Services/ogAdmServer/tests
diff options
context:
space:
mode:
Diffstat (limited to 'admin/Sources/Services/ogAdmServer/tests')
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/clients.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/config/ogAdmServer.cfg8
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/post_clients.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/post_shell_output.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/post_shell_run.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/poweroff.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/reboot.json1
-rwxr-xr-xadmin/Sources/Services/ogAdmServer/tests/run-tests.py41
-rwxr-xr-xadmin/Sources/Services/ogAdmServer/tests/run-tests.sh14
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/session.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/stop.json1
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0001_get_clients.py19
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0002_post_clients.py16
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0003_post_wol.py21
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0004_post_shell_run.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0005_post_shell_output.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0006_post_session.py21
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0007_post_poweroff.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0008_post_reboot.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0009_post_stop.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0010_post_refresh.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0011_post_hardware.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0012_post_software.py20
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0013_nonexistent.py30
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0014_big_request.py19
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/units/test_0015_wrong_headers.py29
-rw-r--r--admin/Sources/Services/ogAdmServer/tests/wol.json1
27 files changed, 387 insertions, 0 deletions
diff --git a/admin/Sources/Services/ogAdmServer/tests/clients.json b/admin/Sources/Services/ogAdmServer/tests/clients.json
new file mode 100644
index 00000000..01672ed3
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/clients.json
@@ -0,0 +1 @@
+curl -X GET http://127.0.0.1:8888/clients
diff --git a/admin/Sources/Services/ogAdmServer/tests/config/ogAdmServer.cfg b/admin/Sources/Services/ogAdmServer/tests/config/ogAdmServer.cfg
new file mode 100644
index 00000000..41d812b6
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/config/ogAdmServer.cfg
@@ -0,0 +1,8 @@
+ServidorAdm=localhost
+PUERTO=2008
+USUARIO=test-db
+PASSWORD=test-db
+datasource=localhost
+CATALOG=test-db
+INTERFACE=eth1
+APITOKEN=07b3bfe728954619b58f0107ad73acc1
diff --git a/admin/Sources/Services/ogAdmServer/tests/post_clients.json b/admin/Sources/Services/ogAdmServer/tests/post_clients.json
new file mode 100644
index 00000000..4667303d
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/post_clients.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ] }
diff --git a/admin/Sources/Services/ogAdmServer/tests/post_shell_output.json b/admin/Sources/Services/ogAdmServer/tests/post_shell_output.json
new file mode 100644
index 00000000..1badfed0
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/post_shell_output.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ]}
diff --git a/admin/Sources/Services/ogAdmServer/tests/post_shell_run.json b/admin/Sources/Services/ogAdmServer/tests/post_shell_run.json
new file mode 100644
index 00000000..1449d055
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/post_shell_run.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ], "run" : "ls" }
diff --git a/admin/Sources/Services/ogAdmServer/tests/poweroff.json b/admin/Sources/Services/ogAdmServer/tests/poweroff.json
new file mode 100644
index 00000000..4667303d
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/poweroff.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ] }
diff --git a/admin/Sources/Services/ogAdmServer/tests/reboot.json b/admin/Sources/Services/ogAdmServer/tests/reboot.json
new file mode 100644
index 00000000..4667303d
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/reboot.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ] }
diff --git a/admin/Sources/Services/ogAdmServer/tests/run-tests.py b/admin/Sources/Services/ogAdmServer/tests/run-tests.py
new file mode 100755
index 00000000..1a59a348
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/run-tests.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import subprocess, glob, os
+
+sql_data = "INSERT INTO aulas (nombreaula, idcentro, urlfoto, grupoid, ubicacion, puestos, modomul, ipmul, pormul, velmul, router, netmask, ntp, dns, proxy, modp2p, timep2p) VALUES ('Aula virtual', 1, 'aula.jpg', 0, 'Despliegue virtual con Vagrant.', 5, 2, '239.194.2.11', 9000, 70, '192.168.56.1', '255.255.255.0', '', '', '', 'peer', 30); INSERT INTO ordenadores (nombreordenador, ip, mac, idaula, idrepositorio, idperfilhard, idmenu, idproautoexec, grupoid, router, mascara, arranque, netiface, netdriver, fotoord) VALUES ('pc2', '192.168.2.1', '0800270E6501', 1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif'), ('pc2', '192.168.2.2', '0800270E6502', 1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif');"
+
+sql_create_user = "CREATE USER 'test-db'@'hostname'; GRANT ALL PRIVILEGES ON *.* To 'test-db'@'hostname' IDENTIFIED BY 'test-db';"
+
+sql_delete_user = "DROP USER 'test-db'@'hostname';"
+
+def start_mysql():
+
+ subprocess.run(['mysqladmin', 'drop', '-f', 'test-db'],
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ subprocess.run(['mysqladmin', 'create', 'test-db'])
+ subprocess.run('mysql --default-character-set=utf8 test-db < ../../../../Database/ogAdmBD.sql', shell=True)
+ subprocess.run(['mysql', '-D', 'test-db', '-e', sql_data])
+ subprocess.run(['mysql', '-D', 'test-db', '-e', sql_create_user])
+
+def stop_mysql():
+
+ subprocess.run(['mysql', '-D', 'test-db', '-e', sql_delete_user])
+ subprocess.run(['mysqladmin', 'drop', '-f', 'test-db'])
+
+if os.getuid() is not 0:
+ print('You need to be root to run these tests :-)')
+ exit()
+
+if os.path.isfile('../ogAdmServer') is not True:
+ print('You need to build the ogAdmServer binary to run these tests :-)')
+ exit()
+
+start_mysql();
+
+subprocess.Popen(['../ogAdmServer', '-f', 'config/ogAdmServer.cfg'])
+
+subprocess.run('python3 -m unittest discover -s units -v', shell=True)
+
+stop_mysql();
+
+subprocess.run(['pkill', 'ogAdmServer'])
diff --git a/admin/Sources/Services/ogAdmServer/tests/run-tests.sh b/admin/Sources/Services/ogAdmServer/tests/run-tests.sh
new file mode 100755
index 00000000..f22df02a
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/run-tests.sh
@@ -0,0 +1,14 @@
+API_KEY="07b3bfe728954619b58f0107ad73acc1"
+
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/clients -d @post_clients.json
+curl -X GET -H "Authorization: $API_KEY" http://127.0.0.1:8888/clients
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/wol -d @wol.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/shell/run -d @post_shell_run.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/shell/output -d @post_shell_output.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/session -d @session.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/poweroff -d @poweroff.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/reboot -d @reboot.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/stop -d @stop.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/refresh -d @refresh.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/hardware -d @post_clients.json
+curl -X POST -H "Authorization: $API_KEY" http://127.0.0.1:8888/software -d @post_clients.json
diff --git a/admin/Sources/Services/ogAdmServer/tests/session.json b/admin/Sources/Services/ogAdmServer/tests/session.json
new file mode 100644
index 00000000..1b473c4c
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/session.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ], "disk" : "0", "partition" : "1"}
diff --git a/admin/Sources/Services/ogAdmServer/tests/stop.json b/admin/Sources/Services/ogAdmServer/tests/stop.json
new file mode 100644
index 00000000..4667303d
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/stop.json
@@ -0,0 +1 @@
+{ "clients" : [ "192.168.2.1", "192.168.2.2" ] }
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0001_get_clients.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0001_get_clients.py
new file mode 100644
index 00000000..218b41aa
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0001_get_clients.py
@@ -0,0 +1,19 @@
+import requests
+import unittest
+
+class TestGetClientsMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/clients'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_post_without_data(self):
+ returned = requests.post(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 400)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0002_post_clients.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0002_post_clients.py
new file mode 100644
index 00000000..1aae349e
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0002_post_clients.py
@@ -0,0 +1,16 @@
+import requests
+import unittest
+
+class TestPostClientsMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/clients'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0003_post_wol.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0003_post_wol.py
new file mode 100644
index 00000000..e997aff6
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0003_post_wol.py
@@ -0,0 +1,21 @@
+import requests
+import unittest
+
+class TestPostWolMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/wol'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'type' : 'broadcast', 'clients' : [ { 'addr' : '192.168.2.1',
+ 'mac' : '00AABBCCDD01' } ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0004_post_shell_run.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0004_post_shell_run.py
new file mode 100644
index 00000000..2a330be9
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0004_post_shell_run.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostShellRunMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/shell/run'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ], 'run' : 'ls' }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..1c6f7a3a
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0005_post_shell_output.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostShellOutputMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/shell/output'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..544ae2ab
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0006_post_session.py
@@ -0,0 +1,21 @@
+import requests
+import unittest
+
+class TestPostSessionMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/session'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ],
+ 'disk' : '0', 'partition' : '1'}
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..d2d5b15d
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0007_post_poweroff.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostPoweroffMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/poweroff'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..5ac4dc24
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0008_post_reboot.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostRebootMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/reboot'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..7aa96ff8
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0009_post_stop.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostStopMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/stop'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..745bdbe5
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0010_post_refresh.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostRefreshMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/refresh'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..6d9c16a9
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0011_post_hardware.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostHardwareMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/hardware'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
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
new file mode 100644
index 00000000..049a3ec8
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0012_post_software.py
@@ -0,0 +1,20 @@
+import requests
+import unittest
+
+class TestPostSoftwareMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/software'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0013_nonexistent.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0013_nonexistent.py
new file mode 100644
index 00000000..b2e908ce
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0013_nonexistent.py
@@ -0,0 +1,30 @@
+import requests
+import unittest
+
+class TestPostNonexistentMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/nonexistent'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.wrong_headers = {'Authorization' :
+ 'WrongWrongWrongWrongWrongWrongWr'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers, json=self.json)
+ self.assertEqual(returned.status_code, 404)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 404)
+
+ def test_post_unauthenticated(self):
+ returned = requests.post(self.url, headers=self.wrong_headers)
+ self.assertEqual(returned.status_code, 401)
+
+ def test_post_without_json(self):
+ returned = requests.post(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 404)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0014_big_request.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0014_big_request.py
new file mode 100644
index 00000000..5e5e2d71
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0014_big_request.py
@@ -0,0 +1,19 @@
+import requests
+import unittest
+
+MAX_REQ_SIZE = 4096
+
+class TestBigRequest(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/clients'
+ self.data = 'X' * MAX_REQ_SIZE
+
+ def test_post(self):
+ with self.assertRaises(requests.exceptions.ConnectionError) as context:
+ requests.post(self.url, data=self.data)
+
+ self.assertTrue('Connection reset by peer' in str(context.exception))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/units/test_0015_wrong_headers.py b/admin/Sources/Services/ogAdmServer/tests/units/test_0015_wrong_headers.py
new file mode 100644
index 00000000..8a353217
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/units/test_0015_wrong_headers.py
@@ -0,0 +1,29 @@
+import requests
+import unittest
+
+class TestPostWrongHeaders(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/clients'
+ self.too_large_content_length_headers = {'Authorization' :
+ '07b3bfe728954619b58f0107ad73acc1', 'Content-Length' :
+ '999999999999999999999999999999999999999999999999999999999'}
+ self.too_large_auth_headers = {'Authorization' :
+ 'TooLongoTooLongTooLongTooLongTooLongTooLongTooLongTooLong'
+ 'TooLongoTooLongTooLongTooLongTooLongTooLongTooLongTooLong'
+ 'TooLongoTooLongTooLongTooLongTooLongTooLongTooLongTooLong'}
+ self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
+
+ def test_post_too_large_content(self):
+ with self.assertRaises(requests.exceptions.ConnectionError) as context:
+ returned = requests.post(self.url,
+ headers=self.too_large_content_length_headers)
+
+ self.assertTrue('Connection aborted' in str(context.exception))
+
+ def test_post_too_large_auth(self):
+ returned = requests.post(self.url, headers=self.too_large_auth_headers)
+ self.assertEqual(returned.status_code, 401)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/admin/Sources/Services/ogAdmServer/tests/wol.json b/admin/Sources/Services/ogAdmServer/tests/wol.json
new file mode 100644
index 00000000..2a2f799f
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/tests/wol.json
@@ -0,0 +1 @@
+{ "type" : "unicast", "clients" : [ { "addr" : "192.168.2.1", "mac" : "00AABBCCDD01" } ] }