Skip to content

Commit

Permalink
Change commands used for some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
remip2 committed Nov 19, 2024
1 parent 3eb16e0 commit d6a3a05
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
11 changes: 7 additions & 4 deletions tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 13 additions & 10 deletions tests/test_format_ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d6a3a05

Please sign in to comment.