summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2021-04-16 13:39:03 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-04-19 19:05:15 +0200
commitc2c6ce93b1feecbcc79b4d52cf68823f14e88410 (patch)
treec2ce352891770bfffcc3001a733ea7e1093af2b1
parent0b5c0813fa253e4f020fc4ee09a2501f96329337 (diff)
#915 Add large HTTP response test
This commit adds a test for HTTP responses that are too large to fit in ogServer response buffer. It also moves the basic sql data used for the other tests to its own file, easing its reuse in several files.
-rw-r--r--tests/config/basic_data.sql41
-rwxr-xr-xtests/run-tests.py3
-rw-r--r--tests/units/test_0032_big_response.py26
3 files changed, 69 insertions, 1 deletions
diff --git a/tests/config/basic_data.sql b/tests/config/basic_data.sql
new file mode 100644
index 0000000..aca246d
--- /dev/null
+++ b/tests/config/basic_data.sql
@@ -0,0 +1,41 @@
+
+DELETE FROM centros;
+INSERT INTO centros (
+ idcentro, nombrecentro, identidad, comentarios, directorio)
+VALUES
+(1, 'Center', 1, '', '');
+
+DELETE FROM aulas;
+INSERT INTO aulas (
+ nombreaula, idcentro, urlfoto, grupoid,
+ ubicacion, puestos, modomul, ipmul,
+ pormul, velmul, router, netmask, ntp,
+ dns, proxy, modp2p, timep2p
+)
+VALUES
+ (
+ 'Room', 1, 'aula.jpg', 0, 'Test room.',
+ 5, 2, '239.194.2.11', 9000, 70, '192.168.56.1',
+ '255.255.255.0', '', '', '', 'peer',
+ 30
+ );
+
+DELETE FROM ordenadores;
+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'
+ );
+
diff --git a/tests/run-tests.py b/tests/run-tests.py
index 90a0b2d..f252331 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -14,7 +14,8 @@ def start_mysql():
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run(['mysqladmin', 'create', 'test-db'])
subprocess.run('mysql --default-character-set=utf8 test-db < ../cfg/ogAdmBD.sql', shell=True)
- subprocess.run(['mysql', '-D', 'test-db', '-e', sql_data])
+ subprocess.run('mysql --default-character-set=utf8 test-db '
+ '< config/basic_data.sql', shell=True)
subprocess.run(['mysql', '-D', 'test-db', '-e', sql_create_user])
def stop_mysql():
diff --git a/tests/units/test_0032_big_response.py b/tests/units/test_0032_big_response.py
new file mode 100644
index 0000000..49dee76
--- /dev/null
+++ b/tests/units/test_0032_big_response.py
@@ -0,0 +1,26 @@
+import subprocess
+import requests
+import unittest
+import tempfile
+
+class TestBigResponse(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/scopes'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.query = tempfile.NamedTemporaryFile()
+ self.query.write(b'INSERT INTO centros (nombrecentro, identidad, '
+ + b'comentarios, directorio) VALUES '
+ + b'("Center", 1, "", ""),' * 5000
+ + b'("Center", 1, "", "");')
+
+ def test_get(self):
+ subprocess.run('mysql --default-character-set=utf8 test-db < '
+ + self.query.name, shell=True)
+ returned = requests.get(self.url, headers=self.headers)
+ subprocess.run('mysql --default-character-set=utf8 test-db '
+ '< config/basic_data.sql', shell=True)
+ self.assertEqual(returned.status_code, 400)
+
+if __name__ == '__main__':
+ unittest.main()