From: Andrew Lewis Date: Thu, 4 Aug 2016 10:29:45 +0000 (+0100) Subject: [Test] Unify some configs X-Git-Tag: 1.3.2~51 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=581db041d2a8506581408c376a6edc37f8d2e9ca;p=rspamd.git [Test] Unify some configs --- diff --git a/test/functional/cases/102_maps.robot b/test/functional/cases/102_maps.robot deleted file mode 100644 index 1c7bcb3bc..000000000 --- a/test/functional/cases/102_maps.robot +++ /dev/null @@ -1,115 +0,0 @@ -*** Settings *** -Suite Setup Generic Setup -Suite Teardown Generic Teardown -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/maps.conf -${MESSAGE} ${TESTDIR}/messages/spam_message.eml -${UTF_MESSAGE} ${TESTDIR}/messages/utf.eml -${RSPAMD_SCOPE} Suite - -*** Test Cases *** -MAP - DNSBL HIT - ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.2 - Check Rspamc ${result} DNSBL_MAP - -MAP - DNSBL MISS - ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 - Check Rspamc ${result} DNSBL_MAP inverse=1 rc_noinverse=1 - -MAP - IP HIT - ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 - Check Rspamc ${result} IP_MAP - -MAP - IP MISS - ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.2 - Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 - -MAP - IP MASK - ${result} = Scan Message With Rspamc ${MESSAGE} -i 10.1.0.10 - Check Rspamc ${result} IP_MAP - -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 - -MAP - IP V6 - ${result} = Scan Message With Rspamc ${MESSAGE} -i ::1 - Check Rspamc ${result} IP_MAP - -MAP - IP V6 MISS - ${result} = Scan Message With Rspamc ${MESSAGE} -i fe80::1 - Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 - -MAP - FROM - ${result} = Scan Message With Rspamc ${MESSAGE} --from user@example.com - Check Rspamc ${result} FROM_MAP - -MAP - FROM MISS - ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.com - Check Rspamc ${result} FROM_MAP inverse=1 rc_noinverse=1 - -MAP - FROM REGEXP - ${result} = Scan Message With Rspamc ${MESSAGE} --from user123@test.com - Check Rspamc ${result} REGEXP_MAP - ${result} = Scan Message With Rspamc ${MESSAGE} --from somebody@exAmplE.com - Check Rspamc ${result} REGEXP_MAP - -MAP - FROM REGEXP MISS - ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.org - Check Rspamc ${result} REGEXP_MAP inverse=1 rc_noinverse=1 - -MAP - DEPENDS HIT - ${result} = Scan Message With Rspamc ${MESSAGE} -i 147.243.1.47 --from user123@microsoft.com - Check Rspamc ${result} DEPS_MAP - -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 - -MAP - MULSYM PLAIN - ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user1@example.com - Check Rspamc ${result} RCPT_MAP - -MAP - MULSYM SCORE - ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user2@example.com - Check Rspamc ${result} RCPT_MAP (10.0 - -MAP - MULSYM SYMBOL - ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user3@example.com - Check Rspamc ${result} SYM1 (1.0 - -MAP - MULSYM SYMBOL MISS - ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user4@example.com - Check Rspamc ${result} RCPT_MAP (1.0 - -MAP - MULSYM SYMBOL + SCORE - ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user5@example.com - Check Rspamc ${result} SYM1 (-10.0 - -MAP - UTF - ${result} = Scan Message With Rspamc ${UTF_MESSAGE} - Check Rspamc ${result} HEADER_MAP - -MAP - UTF MISS - ${result} = Scan Message With Rspamc ${MESSAGE} - Check Rspamc ${result} HEADER_MAP inverse=1 rc_noinverse=1 - -MAP - HOSTNAME - ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname example.com - Check Rspamc ${result} HOSTNAME_MAP - -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 - -MAP - CDB - HOSTNAME - ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname example.com - Check Rspamc ${result} HOSTNAME_MAP - -MAP - CDB - 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 diff --git a/test/functional/cases/102_multimap.robot b/test/functional/cases/102_multimap.robot new file mode 100644 index 000000000..9d02ca666 --- /dev/null +++ b/test/functional/cases/102_multimap.robot @@ -0,0 +1,121 @@ +*** Settings *** +Suite Setup Multimap Setup +Suite Teardown Generic Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/plugins.conf +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${UTF_MESSAGE} ${TESTDIR}/messages/utf.eml +${RSPAMD_SCOPE} Suite + +*** Test Cases *** +MAP - DNSBL HIT + ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.2 + Check Rspamc ${result} DNSBL_MAP + +MAP - DNSBL MISS + ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 + Check Rspamc ${result} DNSBL_MAP inverse=1 rc_noinverse=1 + +MAP - IP HIT + ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.1 + Check Rspamc ${result} IP_MAP + +MAP - IP MISS + ${result} = Scan Message With Rspamc ${MESSAGE} -i 127.0.0.2 + Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 + +MAP - IP MASK + ${result} = Scan Message With Rspamc ${MESSAGE} -i 10.1.0.10 + Check Rspamc ${result} IP_MAP + +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 + +MAP - IP V6 + ${result} = Scan Message With Rspamc ${MESSAGE} -i ::1 + Check Rspamc ${result} IP_MAP + +MAP - IP V6 MISS + ${result} = Scan Message With Rspamc ${MESSAGE} -i fe80::1 + Check Rspamc ${result} IP_MAP inverse=1 rc_noinverse=1 + +MAP - FROM + ${result} = Scan Message With Rspamc ${MESSAGE} --from user@example.com + Check Rspamc ${result} FROM_MAP + +MAP - FROM MISS + ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.com + Check Rspamc ${result} FROM_MAP inverse=1 rc_noinverse=1 + +MAP - FROM REGEXP + ${result} = Scan Message With Rspamc ${MESSAGE} --from user123@test.com + Check Rspamc ${result} REGEXP_MAP + ${result} = Scan Message With Rspamc ${MESSAGE} --from somebody@exAmplE.com + Check Rspamc ${result} REGEXP_MAP + +MAP - FROM REGEXP MISS + ${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.org + Check Rspamc ${result} REGEXP_MAP inverse=1 rc_noinverse=1 + +MAP - DEPENDS HIT + ${result} = Scan Message With Rspamc ${MESSAGE} -i 147.243.1.47 --from user123@microsoft.com + Check Rspamc ${result} DEPS_MAP + +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 + +MAP - MULSYM PLAIN + ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user1@example.com + Check Rspamc ${result} RCPT_MAP + +MAP - MULSYM SCORE + ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user2@example.com + Check Rspamc ${result} RCPT_MAP (10.0 + +MAP - MULSYM SYMBOL + ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user3@example.com + Check Rspamc ${result} SYM1 (1.0 + +MAP - MULSYM SYMBOL MISS + ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user4@example.com + Check Rspamc ${result} RCPT_MAP (1.0 + +MAP - MULSYM SYMBOL + SCORE + ${result} = Scan Message With Rspamc ${MESSAGE} --rcpt user5@example.com + Check Rspamc ${result} SYM1 (-10.0 + +MAP - UTF + ${result} = Scan Message With Rspamc ${UTF_MESSAGE} + Check Rspamc ${result} HEADER_MAP + +MAP - UTF MISS + ${result} = Scan Message With Rspamc ${MESSAGE} + Check Rspamc ${result} HEADER_MAP inverse=1 rc_noinverse=1 + +MAP - HOSTNAME + ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname example.com + Check Rspamc ${result} HOSTNAME_MAP + +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 + +MAP - CDB - HOSTNAME + ${result} = Scan Message With Rspamc ${MESSAGE} --ip 127.0.0.1 --hostname example.com + Check Rspamc ${result} HOSTNAME_MAP + +MAP - CDB - 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 + +*** Keywords *** +Multimap Setup + ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/multimap.conf + Set Suite Variable ${PLUGIN_CONFIG} + Generic Setup PLUGIN_CONFIG diff --git a/test/functional/cases/105_archives.robot b/test/functional/cases/105_archives.robot deleted file mode 100644 index 16a14bfda..000000000 --- a/test/functional/cases/105_archives.robot +++ /dev/null @@ -1,23 +0,0 @@ -*** Settings *** -Suite Setup Generic Setup -Suite Teardown Generic Teardown -Library ${TESTDIR}/lib/rspamd.py -Resource ${TESTDIR}/lib/rspamd.robot -Variables ${TESTDIR}/lib/vars.py - -*** Variables *** -${CONFIG} ${TESTDIR}/configs/plugins.conf -${RSPAMD_SCOPE} Suite - -*** Test Cases *** -Zip - ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip.eml - Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 - -Zip Double Bad Extension - ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip-doublebad.eml - Check Rspamc ${result} MIME_DOUBLE_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[\\.pdf\\.exe\\]\\n re=1 - -Rar4 - ${result} = Scan Message With Rspamc ${TESTDIR}/messages/rar4.eml - Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 diff --git a/test/functional/cases/105_mimetypes.robot b/test/functional/cases/105_mimetypes.robot new file mode 100644 index 000000000..c67784f25 --- /dev/null +++ b/test/functional/cases/105_mimetypes.robot @@ -0,0 +1,29 @@ +*** Settings *** +Suite Setup MIMETypes Setup +Suite Teardown Generic Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/plugins.conf +${RSPAMD_SCOPE} Suite + +*** Test Cases *** +Zip + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip.eml + Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 + +Zip Double Bad Extension + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip-doublebad.eml + Check Rspamc ${result} MIME_DOUBLE_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[\\.pdf\\.exe\\]\\n re=1 + +Rar4 + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/rar4.eml + Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1 + +*** Keywords *** +MIMETypes Setup + ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/mime_types.conf + Set Suite Variable ${PLUGIN_CONFIG} + Generic Setup PLUGIN_CONFIG diff --git a/test/functional/configs/maps.conf b/test/functional/configs/maps.conf deleted file mode 100644 index 09a8e8cd7..000000000 --- a/test/functional/configs/maps.conf +++ /dev/null @@ -1,80 +0,0 @@ -options = { - filters = ["spf", "dkim", "regexp"] - url_tld = "${TESTDIR}/../lua/unit/test_tld.dat" - pidfile = "${TMPDIR}/rspamd.pid" - lua_path = "${TESTDIR}/../../contrib/lua-fun/?.lua" -} -logging = { - type = "file", - level = "debug" - filename = "${TMPDIR}/rspamd.log" -} -metric = { - name = "default", - actions = { - reject = 100500, - } - unknown_weight = 1 -} - -worker { - type = normal - bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL} - count = 1 - keypair { - pubkey = "${KEY_PUB1}"; - privkey = "${KEY_PVT1}"; - } -} -modules { - path = "${TESTDIR}/../../src/plugins/lua/" -} -multimap { - DNSBL_MAP { - type = "dnsbl"; - map = "rspamd.com"; - } - IP_MAP { - type = "ip"; - map = "${TESTDIR}/configs/maps/ip.list"; - } - FROM_MAP { - type = "from"; - filter = "email:domain"; - map = "${TESTDIR}/configs/maps/domains.list"; - } - REGEXP_MAP { - type = "from"; - filter = "email:addr"; - regexp = true; - map = "${TESTDIR}/configs/maps/regexp.list"; - } - DEPS_MAP { - type = "from"; - filter = "email:addr"; - regexp = true; - map = "${TESTDIR}/configs/maps/regexp.list"; - require_symbols = "R_SPF_ALLOW & REGEXP_MAP & !FROM_MAP"; - } - RCPT_MAP { - type = "rcpt"; - filter = "email:addr"; - symbols = ["SYM1"]; - map = "${TESTDIR}/configs/maps/multiple.list"; - } - HEADER_MAP { - type = "header"; - header = "To"; - filter = "email:name"; - map = "${TESTDIR}/configs/maps/utf.list"; - regexp = true; - } - HOSTNAME_MAP { - type = "hostname"; - map = "${TESTDIR}/configs/maps/domains.list"; - } - HOSTNAME_MAP_CDB { - type = "hostname"; - map = "cdb://${TESTDIR}/configs/maps/domains.cdb"; - } -} diff --git a/test/functional/configs/mime_types.conf b/test/functional/configs/mime_types.conf new file mode 100644 index 000000000..4aa1ac0ef --- /dev/null +++ b/test/functional/configs/mime_types.conf @@ -0,0 +1,15 @@ +mime_types { + file = "${TESTDIR}/../../../conf/mime_types.inc"; + extension_map { + html = "text/html"; + txt [ + "message/disposition-notification", + "text/plain", + "text/rfc822-headers", + ] + pdf [ + "application/octet-stream", + "application/pdf", + ] + } +} diff --git a/test/functional/configs/multimap.conf b/test/functional/configs/multimap.conf new file mode 100644 index 000000000..334b07e02 --- /dev/null +++ b/test/functional/configs/multimap.conf @@ -0,0 +1,49 @@ +multimap { + DNSBL_MAP { + type = "dnsbl"; + map = "rspamd.com"; + } + IP_MAP { + type = "ip"; + map = "${TESTDIR}/configs/maps/ip.list"; + } + FROM_MAP { + type = "from"; + filter = "email:domain"; + map = "${TESTDIR}/configs/maps/domains.list"; + } + REGEXP_MAP { + type = "from"; + filter = "email:addr"; + regexp = true; + map = "${TESTDIR}/configs/maps/regexp.list"; + } + DEPS_MAP { + type = "from"; + filter = "email:addr"; + regexp = true; + map = "${TESTDIR}/configs/maps/regexp.list"; + require_symbols = "R_SPF_ALLOW & REGEXP_MAP & !FROM_MAP"; + } + RCPT_MAP { + type = "rcpt"; + filter = "email:addr"; + symbols = ["SYM1"]; + map = "${TESTDIR}/configs/maps/multiple.list"; + } + HEADER_MAP { + type = "header"; + header = "To"; + filter = "email:name"; + map = "${TESTDIR}/configs/maps/utf.list"; + regexp = true; + } + HOSTNAME_MAP { + type = "hostname"; + map = "${TESTDIR}/configs/maps/domains.list"; + } + HOSTNAME_MAP_CDB { + type = "hostname"; + map = "cdb://${TESTDIR}/configs/maps/domains.cdb"; + } +} diff --git a/test/functional/configs/plugins.conf b/test/functional/configs/plugins.conf index 6eded737a..2beb7b764 100644 --- a/test/functional/configs/plugins.conf +++ b/test/functional/configs/plugins.conf @@ -1,5 +1,8 @@ options = { + filters = ["spf", "dkim", "regexp"] + url_tld = "${TESTDIR}/../lua/unit/test_tld.dat" pidfile = "${TMPDIR}/rspamd.pid" + lua_path = "${TESTDIR}/../../contrib/lua-fun/?.lua" } logging = { type = "file", @@ -18,21 +21,7 @@ worker { bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL} count = 1 } -mime_types { - file = "${TESTDIR}/../../../conf/mime_types.inc"; - extension_map { - html = "text/html"; - txt [ - "message/disposition-notification", - "text/plain", - "text/rfc822-headers", - ] - pdf [ - "application/octet-stream", - "application/pdf", - ] - } -} modules { path = "${TESTDIR}/../../src/plugins/lua/" } +${PLUGIN_CONFIG}