aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/cases/160_antivirus.robot
blob: 2aab365383b016a290e3338019ef87c45203858f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
*** Settings ***
Suite Setup     Antivirus Setup
Suite Teardown  Antivirus Teardown
Library         Process
Library         ${TESTDIR}/lib/rspamd.py
Resource        ${TESTDIR}/lib/rspamd.robot
Variables       ${TESTDIR}/lib/vars.py

*** Variables ***
${CONFIG}       ${TESTDIR}/configs/antivirus.conf
${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
${MESSAGE2}     ${TESTDIR}/messages/freemail.eml
${REDIS_SCOPE}  Suite
${RSPAMD_SCOPE}  Suite
${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat

*** Test Cases ***
CLAMAV MISS
  Run Dummy Clam  ${PORT_CLAM}
  Scan File  ${MESSAGE}
  Do Not Expect Symbol  CLAM_VIRUS
  Shutdown clamav

CLAMAV HIT
  Run Dummy Clam  ${PORT_CLAM}  1
  Scan File  ${MESSAGE2}
  Expect Symbol  CLAM_VIRUS
  Do Not Expect Symbol  CLAMAV_VIRUS_FAIL
  Shutdown clamav

CLAMAV CACHE HIT
  Scan File  ${MESSAGE2}
  Expect Symbol  CLAM_VIRUS
  Do Not Expect Symbol  CLAMAV_VIRUS_FAIL

CLAMAV CACHE MISS
  Scan File  ${MESSAGE}
  Do Not Expect Symbol  CLAM_VIRUS
  Do Not Expect Symbol  CLAMAV_VIRUS_FAIL

FPROT MISS
  Run Dummy Fprot  ${PORT_FPROT}
  Scan File  ${MESSAGE2}
  Do Not Expect Symbol  FPROT_VIRUS
  Do Not Expect Symbol  FPROT_EICAR
  Shutdown fport

FPROT HIT - PATTERN
  Run Dummy Fprot  ${PORT_FPROT}  1
  Run Dummy Fprot  ${PORT_FPROT2_DUPLICATE}  1  /tmp/dummy_fprot_dupe.pid
  Scan File  ${MESSAGE}
  Expect Symbol  FPROT_EICAR
  Do Not Expect Symbol  CLAMAV_VIRUS
  # Also check ordered pattern match
  Expect Symbol  FPROT2_VIRUS_DUPLICATE_PATTERN
  Do Not Expect Symbol  FPROT2_VIRUS_DUPLICATE_DEFAULT
  Do Not Expect Symbol  FPROT2_VIRUS_DUPLICATE_NOPE
  Shutdown fport
  Shutdown fport duplicate

FPROT CACHE HIT
  Scan File  ${MESSAGE}
  Expect Symbol  FPROT_EICAR
  Do Not Expect Symbol  CLAMAV_VIRUS
  # Also check ordered pattern match
  Expect Symbol  FPROT2_VIRUS_DUPLICATE_PATTERN
  Do Not Expect Symbol  FPROT2_VIRUS_DUPLICATE_DEFAULT

FPROT CACHE MISS
  Scan File  ${MESSAGE2}
  Do Not Expect Symbol  FPROT_VIRUS

AVAST MISS
  Run Dummy Avast  ${PORT_AVAST}
  Scan File  ${MESSAGE}
  Do Not Expect Symbol  AVAST_VIRUS
  Shutdown avast

AVAST HIT
  Run Dummy Avast  ${PORT_AVAST}  1
  Scan File  ${MESSAGE2}
  Expect Symbol  AVAST_VIRUS
  Do Not Expect Symbol  AVAST_VIRUS_FAIL
  Shutdown avast

AVAST CACHE HIT
  Scan File  ${MESSAGE2}
  Expect Symbol  AVAST_VIRUS
  Do Not Expect Symbol  AVAST_VIRUS_FAIL

AVAST CACHE MISS
  Scan File  ${MESSAGE}
  Do Not Expect Symbol  AVAST_VIRUS
  Do Not Expect Symbol  AVAST_VIRUS_FAIL

*** Keywords ***
Antivirus Setup
  New Setup  PORT_CLAM=${PORT_CLAM}  PORT_FPROT=${PORT_FPROT}  PORT_AVAST=${PORT_AVAST}
  ...  PORT_FPROT2_DUPLICATE=${PORT_FPROT2_DUPLICATE}
  Run Redis

Antivirus Teardown
  Normal Teardown
  Shutdown Process With Children  ${REDIS_PID}
  Shutdown clamav
  Shutdown fport
  Shutdown avast
  Terminate All Processes    kill=True

Shutdown clamav
  ${clamav_pid} =  Get File if exists  /tmp/dummy_clamav.pid
  Run Keyword if  ${clamav_pid}  Shutdown Process With Children  ${clamav_pid}

Shutdown fport
  ${fport_pid} =  Get File if exists  /tmp/dummy_fprot.pid
  Run Keyword if  ${fport_pid}  Shutdown Process With Children  ${fport_pid}

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
  [Arguments]  @{varargs}
  ${process} =  Start Process  @{varargs}
  ${pid} =  Get From List  ${varargs}  -1
  ${pass} =  Run Keyword And Return Status  Wait Until Created  ${pid}
  Run Keyword If  ${pass}  Return From Keyword
  Wait For Process  ${process}
  ${res} =  Get Process Result  ${process}
  Log To Console  ${res.stdout}
  Log To Console  ${res.stderr}
  Fail  Dummy server failed to start

Run Dummy Clam
  [Arguments]  ${port}  ${found}=  ${pid}=/tmp/dummy_clamav.pid
  Run Dummy  ${TESTDIR}/util/dummy_clam.py  ${port}  ${found}  ${pid}

Run Dummy Fprot
  [Arguments]  ${port}  ${found}=  ${pid}=/tmp/dummy_fprot.pid
  Run Dummy  ${TESTDIR}/util/dummy_fprot.py  ${port}  ${found}  ${pid}

Run Dummy Avast
  [Arguments]  ${port}  ${found}=  ${pid}=/tmp/dummy_avast.pid
  Run Dummy  ${TESTDIR}/util/dummy_avast.py  ${port}  ${found}  ${pid}