aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/102_multimap.robot35
-rw-r--r--test/functional/configs/multimap.conf16
-rw-r--r--test/functional/lib/rspamd.robot8
3 files changed, 58 insertions, 1 deletions
diff --git a/test/functional/cases/102_multimap.robot b/test/functional/cases/102_multimap.robot
index dd6f103ec..f88fd9da6 100644
--- a/test/functional/cases/102_multimap.robot
+++ b/test/functional/cases/102_multimap.robot
@@ -1,6 +1,6 @@
*** Settings ***
Suite Setup Multimap Setup
-Suite Teardown Generic Teardown
+Suite Teardown Multimap Teardown
Library ${TESTDIR}/lib/rspamd.py
Resource ${TESTDIR}/lib/rspamd.robot
Variables ${TESTDIR}/lib/vars.py
@@ -9,6 +9,7 @@ Variables ${TESTDIR}/lib/vars.py
${CONFIG} ${TESTDIR}/configs/plugins.conf
${MESSAGE} ${TESTDIR}/messages/spam_message.eml
${UTF_MESSAGE} ${TESTDIR}/messages/utf.eml
+${REDIS_SCOPE} Suite
${RSPAMD_SCOPE} Suite
*** Test Cases ***
@@ -114,8 +115,40 @@ MAP - CDB - HOSTNAME MISS
${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname rspamd.com
Check Rspamc ${result} CDB_HOSTNAME inverse=1 rc_noinverse=1
+MAP - REDIS - HOSTNAME
+ Redis HSET hostname redistest.example.net ${EMPTY}
+ ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname redistest.example.net
+ Check Rspamc ${result} REDIS_HOSTNAME
+
+MAP - REDIS - HOSTNAME MISS
+ ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname rspamd.com
+ Check Rspamc ${result} REDIS_HOSTNAME inverse=1 rc_noinverse=1
+
+MAP - REDIS - IP
+ Redis HSET ipaddr 127.0.0.1 ${EMPTY}
+ ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1
+ Check Rspamc ${result} REDIS_IPADDR
+
+MAP - REDIS - IP - MISS
+ ${result} = Scan Message With Rspamc ${MESSAGE} --ip 8.8.8.8
+ Check Rspamc ${result} REDIS_IPADDR inverse=1 rc_noinverse=1
+
+MAP - REDIS - FROM
+ Redis HSET emailaddr from@rspamd.tk ${EMPTY}
+ ${result} = Scan Message With Rspamc ${MESSAGE} --from from@rspamd.tk
+ Check Rspamc ${result} REDIS_FROMADDR
+
+MAP - REDIS - FROM MISS
+ ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.com
+ Check Rspamc ${result} REDIS_FROMADDR inverse=1 rc_noinverse=1
+
*** Keywords ***
Multimap Setup
${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/multimap.conf
Set Suite Variable ${PLUGIN_CONFIG}
Generic Setup PLUGIN_CONFIG
+ Run Redis
+
+Multimap Teardown
+ Shutdown Process With Children ${REDIS_PID}
+ Generic Teardown
diff --git a/test/functional/configs/multimap.conf b/test/functional/configs/multimap.conf
index 1cb010d8a..7c75c7a91 100644
--- a/test/functional/configs/multimap.conf
+++ b/test/functional/configs/multimap.conf
@@ -1,3 +1,6 @@
+redis {
+ servers = "${REDIS_ADDR}:${REDIS_PORT}";
+}
multimap {
DNSBL_MAP {
type = "dnsbl";
@@ -46,4 +49,17 @@ multimap {
type = "hostname";
map = "cdb://${TESTDIR}/configs/maps/domains.cdb";
}
+ REDIS_HOSTNAME {
+ type = "hostname";
+ map = "redis://hostname";
+ }
+ REDIS_IPADDR {
+ type = "ip";
+ map = "redis://ipaddr";
+ }
+ REDIS_FROMADDR {
+ type = "from";
+ filter = "email:addr";
+ map = "redis://emailaddr";
+ }
}
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index a4769f4a5..2c6fbfc43 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -70,6 +70,14 @@ Log Logs
Log ${the_log}
[Return] ${position}
+Redis HSET
+ [Arguments] ${hash} ${key} ${value}
+ ${result} = Run Process redis-cli -h ${REDIS_ADDR} -p ${REDIS_PORT}
+ ... HSET ${hash} ${key} ${value}
+ Run Keyword If ${result.rc} != 0 Log ${result.stderr}
+ Log ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0
+
Run Redis
${template} = Get File ${TESTDIR}/configs/redis-server.conf
${config} = Replace Variables ${template}