diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-08-12 17:00:56 +0100 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-08-12 17:24:30 +0100 |
commit | 188725d470dc3b9bc9ea3fbc291e05cb7623f2f4 (patch) | |
tree | 9c7918261713b32c9c0ef830f5282c1f859c0abb /test/functional | |
parent | 34696a9cb11cbc8c0c969d52d57936f2ab2b2bf0 (diff) | |
download | rspamd-188725d470dc3b9bc9ea3fbc291e05cb7623f2f4.tar.gz rspamd-188725d470dc3b9bc9ea3fbc291e05cb7623f2f4.zip |
[Test] Some minor updates for tests
- Removed horrible features from test library
- Negative cases for SpamAssassin WLBLEval
- Restructured JSON tests
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/cases/102_multimap.robot | 26 | ||||
-rw-r--r-- | test/functional/cases/121_json/100_preresult.robot (renamed from test/functional/cases/121_json.robot) | 13 | ||||
-rw-r--r-- | test/functional/cases/121_json/101_simple.robot | 23 | ||||
-rw-r--r-- | test/functional/cases/121_json/lib.robot | 19 | ||||
-rw-r--r-- | test/functional/cases/135_spamassassin.robot | 12 | ||||
-rw-r--r-- | test/functional/lib/rspamd.robot | 7 |
6 files changed, 72 insertions, 28 deletions
diff --git a/test/functional/cases/102_multimap.robot b/test/functional/cases/102_multimap.robot index f88fd9da6..03db8c854 100644 --- a/test/functional/cases/102_multimap.robot +++ b/test/functional/cases/102_multimap.robot @@ -19,7 +19,7 @@ MAP - DNSBL HIT MAP - DNSBL MISS ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 - Check Rspamc ${result} DNSBL_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} DNSBL_MAP inverse=1 MAP - IP HIT ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 @@ -27,7 +27,7 @@ MAP - IP HIT MAP - IP MISS ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.2 - Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} IP_MAP inverse=1 MAP - IP MASK ${result} = Scan Message With Rspamc ${MESSAGE} -i 10.1.0.10 @@ -35,7 +35,7 @@ MAP - IP MASK MAP - IP MASK MISS ${result} = Scan Message With Rspamc ${MESSAGE} -i 11.1.0.10 - Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} IP_MAP inverse=1 MAP - IP V6 ${result} = Scan Message With Rspamc ${MESSAGE} -i ::1 @@ -43,7 +43,7 @@ MAP - IP V6 MAP - IP V6 MISS ${result} = Scan Message With Rspamc ${MESSAGE} -i fe80::1 - Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} IP_MAP inverse=1 MAP - FROM ${result} = Scan Message With Rspamc ${MESSAGE} --from user@example.com @@ -51,7 +51,7 @@ MAP - FROM MAP - FROM MISS ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.com - Check Rspamc ${result} FROM_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} FROM_MAP inverse=1 MAP - FROM REGEXP ${result} = Scan Message With Rspamc ${MESSAGE} --from user123@test.com @@ -61,7 +61,7 @@ MAP - FROM REGEXP MAP - FROM REGEXP MISS ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.org - Check Rspamc ${result} REGEXP_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} REGEXP_MAP inverse=1 MAP - DEPENDS HIT ${result} = Scan Message With Rspamc ${MESSAGE} -i 147.243.1.47 --from user123@microsoft.com @@ -69,7 +69,7 @@ MAP - DEPENDS HIT MAP - DEPENDS MISS ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 --from user123@microsoft.com - Check Rspamc ${result} DEPS_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} DEPS_MAP inverse=1 MAP - MULSYM PLAIN ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user1@example.com @@ -97,7 +97,7 @@ MAP - UTF MAP - UTF MISS ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} HEADER_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} HEADER_MAP inverse=1 MAP - HOSTNAME ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname example.com @@ -105,7 +105,7 @@ MAP - HOSTNAME MAP - HOSTNAME MISS ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname rspamd.com - Check Rspamc ${result} HOSTNAME_MAP inverse=1 rc_noinverse=1 + Check Rspamc ${result} HOSTNAME_MAP inverse=1 MAP - CDB - HOSTNAME ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname example.com @@ -113,7 +113,7 @@ MAP - CDB - HOSTNAME 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 + Check Rspamc ${result} CDB_HOSTNAME inverse=1 MAP - REDIS - HOSTNAME Redis HSET hostname redistest.example.net ${EMPTY} @@ -122,7 +122,7 @@ MAP - 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 + Check Rspamc ${result} REDIS_HOSTNAME inverse=1 MAP - REDIS - IP Redis HSET ipaddr 127.0.0.1 ${EMPTY} @@ -131,7 +131,7 @@ MAP - REDIS - IP 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 + Check Rspamc ${result} REDIS_IPADDR inverse=1 MAP - REDIS - FROM Redis HSET emailaddr from@rspamd.tk ${EMPTY} @@ -140,7 +140,7 @@ MAP - REDIS - FROM MAP - REDIS - FROM MISS ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.com - Check Rspamc ${result} REDIS_FROMADDR inverse=1 rc_noinverse=1 + Check Rspamc ${result} REDIS_FROMADDR inverse=1 *** Keywords *** Multimap Setup diff --git a/test/functional/cases/121_json.robot b/test/functional/cases/121_json/100_preresult.robot index 2bb432f5a..58682f6f5 100644 --- a/test/functional/cases/121_json.robot +++ b/test/functional/cases/121_json/100_preresult.robot @@ -2,6 +2,7 @@ Suite Setup Generic Setup Suite Teardown Generic Teardown Library ${TESTDIR}/lib/rspamd.py +Resource lib.robot Resource ${TESTDIR}/lib/rspamd.robot Variables ${TESTDIR}/lib/vars.py @@ -13,16 +14,10 @@ ${RSPAMD_SCOPE} Suite *** Test Cases *** Stat - @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /stat - Check JSON @{result}[1] + Stat Test History - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} soft reject - @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /history - Check JSON @{result}[1] + History Test soft reject Scan - ${content} = Get File ${MESSAGE} - @{result} = HTTP POST ${LOCAL_ADDR} ${PORT_NORMAL} /check ${content} - Check JSON @{result}[1] + Scan Test diff --git a/test/functional/cases/121_json/101_simple.robot b/test/functional/cases/121_json/101_simple.robot new file mode 100644 index 000000000..38b6ec11d --- /dev/null +++ b/test/functional/cases/121_json/101_simple.robot @@ -0,0 +1,23 @@ +*** Settings *** +Suite Setup Generic Setup +Suite Teardown Generic Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource lib.robot +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/lua_test.conf +${LUA_SCRIPT} ${TESTDIR}/lua/simple.lua +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${RSPAMD_SCOPE} Suite + +*** Test Cases *** +Stat + Stat Test + +History + History Test SIMPLE_TEST + +Scan + Scan Test diff --git a/test/functional/cases/121_json/lib.robot b/test/functional/cases/121_json/lib.robot new file mode 100644 index 000000000..e558c7107 --- /dev/null +++ b/test/functional/cases/121_json/lib.robot @@ -0,0 +1,19 @@ +*** Keywords *** +Stat Test + @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /stat + Check JSON @{result}[1] + Should Be Equal As Integers @{result}[0] 200 + +History Test + [Arguments] ${rspamc_expected_result} + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} ${rspamc_expected_result} + @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /history + Check JSON @{result}[1] + Should Be Equal As Integers @{result}[0] 200 + +Scan Test + ${content} = Get File ${MESSAGE} + @{result} = HTTP POST ${LOCAL_ADDR} ${PORT_NORMAL} /check ${content} + Check JSON @{result}[1] + Should Be Equal As Integers @{result}[0] 200 diff --git a/test/functional/cases/135_spamassassin.robot b/test/functional/cases/135_spamassassin.robot index f2c24a294..2e5c0bb59 100644 --- a/test/functional/cases/135_spamassassin.robot +++ b/test/functional/cases/135_spamassassin.robot @@ -36,6 +36,12 @@ WLBL From Whitelist WLBL To Whitelist Should Contain ${BAD_MESSAGE_RESULT.stdout} USER_IN_WHITELIST_TO +WLBL To Blacklist Miss + Should Not Contain ${BAD_MESSAGE_RESULT.stdout} USER_IN_BLACKLIST_TO + +WLBL From Blacklist Miss + Should Not Contain ${BAD_MESSAGE_RESULT.stdout} USER_IN_BLACKLIST ( + WLBL From Blacklist ${UTF_RESULT} = Scan Message With Rspamc ${TESTDIR}/messages/utf.eml Set Suite Variable ${UTF_RESULT} ${UTF_RESULT} @@ -44,6 +50,12 @@ WLBL From Blacklist WLBL To Blacklist Should Contain ${UTF_RESULT.stdout} USER_IN_BLACKLIST_TO +WLBL To Whitelist Miss + Should Not Contain ${UTF_RESULT.stdout} USER_IN_WHITELIST_TO + +WLBL From Whitelist Miss + Should Not Contain ${UTF_RESULT.stdout} USER_IN_WHITELIST ( + *** Keywords *** SpamAssassin Setup ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/spamassassin.conf diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot index 2c6fbfc43..146eabd71 100644 --- a/test/functional/lib/rspamd.robot +++ b/test/functional/lib/rspamd.robot @@ -16,12 +16,7 @@ Check Rspamc \ Run Keyword If ${re} == True Check Rspamc Match Regexp ${result.stdout} ${i} ${inverse} \ ... ELSE Check Rspamc Match String ${result.stdout} ${i} ${inverse} Run Keyword If @{args} == @{EMPTY} Check Rspamc Match Default ${result.stdout} ${inverse} - ${rc_nocheck} = Evaluate 'rc_nocheck' in $kwargs - ${rc_noinverse} = Evaluate 'rc_noinverse' in $kwargs - Run Keyword If ${rc_nocheck} == True Return From Keyword - ${inverse} = Set Variable If ${rc_noinverse} == True False ${inverse} - Run Keyword If ${inverse} == False Should Be Equal As Integers ${result.rc} ${rc} - ... ELSE Should Not Be Equal As Integers ${result.rc} ${rc} + Should Be Equal As Integers ${result.rc} ${rc} Check Rspamc Match Default [Arguments] ${subject} ${inverse} |