diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-08-12 07:51:59 +0100 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-08-12 11:34:37 +0100 |
commit | 46bc488da9c9beaa924a5cd4e71bd8230775f588 (patch) | |
tree | 3f7f6a508be5245ba08128aa965b5090f57a474b /test | |
parent | 198483c33218ce35bac3f2c81fc2ccdbf5c1c90e (diff) | |
download | rspamd-46bc488da9c9beaa924a5cd4e71bd8230775f588.tar.gz rspamd-46bc488da9c9beaa924a5cd4e71bd8230775f588.zip |
[Test] Add tests for redis maps in multimap
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/cases/102_multimap.robot | 35 | ||||
-rw-r--r-- | test/functional/configs/multimap.conf | 16 | ||||
-rw-r--r-- | test/functional/lib/rspamd.robot | 8 |
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} |