${result} = Scan Message With Rspamc ${MESSAGE2}
Check Rspamc ${result} FPROT_VIRUS inverse=1
+AVAST MISS
+ Run Dummy Avast ${PORT_AVAST}
+ ${result} = Scan Message With Rspamc ${MESSAGE}
+ Check Rspamc ${result} AVAST_VIRUS inverse=1
+ Shutdown avast
+
+AVAST HIT
+ Run Dummy Avast ${PORT_AVAST} 1
+ ${result} = Scan Message With Rspamc ${MESSAGE2}
+ Check Rspamc ${result} AVAST_VIRUS
+ Should Not Contain ${result.stdout} AVAST_VIRUS_FAIL
+ Shutdown avast
+
+AVAST CACHE HIT
+ ${result} = Scan Message With Rspamc ${MESSAGE2}
+ Check Rspamc ${result} AVAST_VIRUS
+ Should Not Contain ${result.stdout} AVAST_VIRUS_FAIL
+
+AVAST CACHE MISS
+ ${result} = Scan Message With Rspamc ${MESSAGE}
+ Check Rspamc ${result} AVAST_VIRUS inverse=1
+ Should Not Contain ${result.stdout} AVAST_VIRUS_FAIL
+
*** Keywords ***
Antivirus Setup
${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/antivirus.conf
Shutdown Process With Children ${REDIS_PID}
Shutdown clamav
Shutdown fport
+ Shutdown avast
Terminate All Processes kill=True
Shutdown clamav
${fport_pid} = Get File if exists /tmp/dummy_fprot_dupe.pid
Run Keyword if ${fport_pid} Shutdown Process With Children ${fport_pid}
+Shutdown avast
+ ${avast_pid} = Get File if exists /tmp/dummy_avast.pid
+ Run Keyword if ${avast_pid} Shutdown Process With Children ${avast_pid}
+
Run Dummy Clam
[Arguments] ${port} ${found}=
${result} = Start Process ${TESTDIR}/util/dummy_clam.py ${port} ${found}
[Arguments] ${port} ${found}= ${pid}=/tmp/dummy_fprot.pid
Start Process ${TESTDIR}/util/dummy_fprot.py ${port} ${found} ${pid}
Wait Until Created ${pid}
+
+Run Dummy Avast
+ [Arguments] ${port} ${found}=
+ ${result} = Start Process ${TESTDIR}/util/dummy_avast.py ${port} ${found}
+ Wait Until Created /tmp/dummy_avast.pid
--- /dev/null
+#!/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()