From d6a3a05081d01e01e782d7db3ae24e0034e36f64 Mon Sep 17 00:00:00 2001 From: "remi.pauchet" Date: Tue, 19 Nov 2024 14:13:46 +0100 Subject: [PATCH] Change commands used for some tests. --- tests/test_file.py | 11 +++++++---- tests/test_format_ini.py | 23 +++++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/test_file.py b/tests/test_file.py index 159a0d7..7526fa4 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -36,16 +36,19 @@ def test_upload_download(self): letters = string.ascii_letters + 'éèàÎîô' #generate a random file - content = ("".join( [random.choice(letters) for i in range(2500)] )).encode('utf-8') + content = ( "[Filter] \n pass from network_internals to any #ASCII" + + "".join( [random.choice(letters) for i in range(100)] ) + ).encode('utf-8') with open(self.upload, "wb") as fh: fh.write(content) - response = self.client.send_command('CONFIG COMMUNICATION EMAIL TEMPLATE UPLOAD pvm_summary < ' + self.upload) + response = self.client.send_command('CONFIG SLOT UPLOAD slot=1 name=testUpload < ' + self.upload) self.assertEqual(response.ret, 100) - self.client.send_command('CONFIG COMMUNICATION ACTIVATE') + + response = self.client.send_command('CONFIG SLOT DOWNLOAD slot=1 name=testUpload > ' + self.download) self.assertEqual(response.ret, 100) - response = self.client.send_command('CONFIG COMMUNICATION EMAIL TEMPLATE DOWNLOAD pvm_summary > ' + self.download) + self.client.send_command('CONFIG SLOT DEFAULT type=filter slot=1') self.assertEqual(response.ret, 100) with open(self.download, "rb") as fh: diff --git a/tests/test_format_ini.py b/tests/test_format_ini.py index 6486001..8d4fd72 100644 --- a/tests/test_format_ini.py +++ b/tests/test_format_ini.py @@ -70,19 +70,22 @@ def test_section_line(self): """ section_line format """ expected = { - 'Result': [ - {'id': 'pvm_detailed', 'type': 'pvm', 'name': 'Detailed Vulnerability Mail'}, - {'id': 'pvm_summary', 'type': 'pvm', 'name': 'Summary Vulnerability Mail'}, - {'id': 'app_cert_req', 'type': 'cert_req', 'name': 'Accept the certificate request'}, - {'id': 'rej_cert_req', 'type': 'cert_req', 'name': 'Reject the certificate request'}, - {'id': 'app_user_req', 'type': 'user_req', 'name': 'Accept the user request'}, - {'id': 'rej_user_req', 'type': 'user_req', 'name': 'Reject the user request'}, - {'id': 'sponsor_req', 'type': 'sponsoring', 'name': 'Sponsoring request'}, - {'id': 'smtp_test_msg', 'type': 'smtp_conf', 'name': 'Test SMTP configuration'} + 'Object': [ + {'type': 'host', 'global': '0', 'name': '_TestHost1', 'ip': '10.10.5.5', 'modify': '1', 'comment': ''}, + {'type': 'host', 'global': '0', 'name': '_TestHost2', 'ip': '10.10.5.6', 'modify': '1', 'comment': ''}, + {'type': 'host', 'global': '0', 'name': '_TestHost3', 'ip': '10.10.5.7', 'modify': '1', 'comment': ''} ] } - response = self.client.send_command('CONFIG COMMUNICATION EMAIL TEMPLATE LIST') + self.client.send_command('CONFIG OBJECT HOST NEW name=_TestHost1 ip=10.10.5.5') + self.client.send_command('CONFIG OBJECT HOST NEW name=_TestHost2 ip=10.10.5.6') + self.client.send_command('CONFIG OBJECT HOST NEW name=_TestHost3 ip=10.10.5.7') + + response = self.client.send_command('CONFIG OBJECT LIST type=host search=_Test* searchfield=name start=0') + + self.client.send_command('CONFIG OBJECT HOST DELETE name=_TestHost1') + self.client.send_command('CONFIG OBJECT HOST DELETE name=_TestHost2') + self.client.send_command('CONFIG OBJECT HOST DELETE name=_TestHost3') self.assertEqual(response.data, expected) self.assertEqual(response.ret, 100)