commit 129fa4d: [Test] Add avast test cases

Vsevolod Stakhov vsevolod at highsecure.ru
Sat Feb 1 18:14:14 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-02-01 18:07:05 +0000
URL: https://github.com/rspamd/rspamd/commit/129fa4d45409463c6123d04cbff97a319a4d26c4 (HEAD -> master)

[Test] Add avast test cases

---
 test/functional/cases/160_antivirus.robot          | 33 ++++++++++++++++++++++
 test/functional/configs/antivirus.conf             |  6 ++++
 test/functional/lib/vars.py                        |  1 +
 .../util/{dummy_clam.py => dummy_avast.py}         |  9 ++++--
 4 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/test/functional/cases/160_antivirus.robot b/test/functional/cases/160_antivirus.robot
index c34121dfd..a3e807917 100644
--- a/test/functional/cases/160_antivirus.robot
+++ b/test/functional/cases/160_antivirus.robot
@@ -70,6 +70,29 @@ FPROT CACHE MISS
   ${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
@@ -82,6 +105,7 @@ Antivirus Teardown
   Shutdown Process With Children  ${REDIS_PID}
   Shutdown clamav
   Shutdown fport
+  Shutdown avast
   Terminate All Processes    kill=True
 
 Shutdown clamav
@@ -96,6 +120,10 @@ Shutdown fport duplicate
   ${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}
@@ -105,3 +133,8 @@ Run Dummy Fprot
   [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
diff --git a/test/functional/configs/antivirus.conf b/test/functional/configs/antivirus.conf
index 9aba7bb64..d38c69a42 100644
--- a/test/functional/configs/antivirus.conf
+++ b/test/functional/configs/antivirus.conf
@@ -32,4 +32,10 @@ antivirus {
       FPROT2_VIRUS_DUPLICATE_NOPE5 = "^EICAR_"}
     ];
   }
+  avast {
+      attachments_only = false;
+      symbol = "AVAST_VIRUS";
+      type = "avast";
+      servers = "127.0.0.1:${PORT_AVAST}";
+  }
 }
diff --git a/test/functional/lib/vars.py b/test/functional/lib/vars.py
index 4559db205..d29c31c7b 100644
--- a/test/functional/lib/vars.py
+++ b/test/functional/lib/vars.py
@@ -15,6 +15,7 @@ PORT_PROXY = 56795
 PORT_CLAM = 56796
 PORT_FPROT = 56797
 PORT_FPROT2_DUPLICATE = 56798
+PORT_AVAST = 56799
 P0F_SOCKET = '/tmp/p0f.sock'
 REDIS_ADDR = u'127.0.0.1'
 REDIS_PORT = 56379
diff --git a/test/functional/util/dummy_clam.py b/test/functional/util/dummy_avast.py
similarity index 71%
copy from test/functional/util/dummy_clam.py
copy to test/functional/util/dummy_avast.py
index d25a63525..55945d8dc 100755
--- a/test/functional/util/dummy_clam.py
+++ b/test/functional/util/dummy_avast.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-PID = "/tmp/dummy_clamav.pid"
+PID = "/tmp/dummy_avast.pid"
 
 import os
 import sys
@@ -14,11 +14,14 @@ except:
 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"stream: Eicar-Test-Signature FOUND\0")
+            self.request.sendall(b"SCAN /some/path/malware/xpaj/00908235ee9e267fa2f4c83fb4304c63af976cbc\t[L]0.0\t0 Eicar\\ [Heur]\r\n")
         else:
-            self.request.sendall(b"stream: OK\0")
+            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__":


More information about the Commits mailing list