diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-01 18:07:05 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-01 18:07:05 +0000 |
commit | 129fa4d45409463c6123d04cbff97a319a4d26c4 (patch) | |
tree | 48e15196e4ab9ad96201854e9c80ad1c7fca94b4 /test/functional/util | |
parent | ee8ec801346e847a70b50f1e344bca041df9fa34 (diff) | |
download | rspamd-129fa4d45409463c6123d04cbff97a319a4d26c4.tar.gz rspamd-129fa4d45409463c6123d04cbff97a319a4d26c4.zip |
[Test] Add avast test cases
Diffstat (limited to 'test/functional/util')
-rwxr-xr-x | test/functional/util/dummy_avast.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/util/dummy_avast.py b/test/functional/util/dummy_avast.py new file mode 100755 index 000000000..55945d8dc --- /dev/null +++ b/test/functional/util/dummy_avast.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +PID = "/tmp/dummy_avast.pid" + +import os +import sys +import socket +import dummy_killer +try: + import SocketServer as socketserver +except: + import socketserver + +class MyTCPHandler(socketserver.BaseRequestHandler): + + def handle(self): + self.request.sendall(b"220 DAEMON\r\n") + self.data = self.request.recv(1024).strip() + self.request.sendall(b"210 SCAN DATA\r\n") + if self.server.foundvirus: + self.request.sendall(b"SCAN /some/path/malware/xpaj/00908235ee9e267fa2f4c83fb4304c63af976cbc\t[L]0.0\t0 Eicar\\ [Heur]\r\n") + else: + self.request.sendall(b"SCAN /some/path/malware/xpaj/00908235ee9e267fa2f4c83fb4304c63af976cbc\t[+]\r\n") + self.request.sendall(b"200 SCAN OK\r\n") + self.request.close() + +if __name__ == "__main__": + HOST = "localhost" + + alen = len(sys.argv) + if alen > 1: + port = int(sys.argv[1]) + if alen >= 3: + foundvirus = bool(sys.argv[2]) + else: + foundvirus = False + else: + port = 3310 + foundvirus = False + + server = socketserver.TCPServer((HOST, port), MyTCPHandler, bind_and_activate=False) + server.allow_reuse_address = True + server.foundvirus = foundvirus + server.server_bind() + server.server_activate() + + dummy_killer.setup_killer(server) + dummy_killer.write_pid(PID) + + try: + server.handle_request() + except socket.error: + print "Socket closed" + + server.server_close() |