aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-15 10:46:31 +0100
committerGitHub <noreply@github.com>2016-08-15 10:46:31 +0100
commitf8718a1191753a141a63ee716aad27df17562df2 (patch)
tree1255397d6911958fb7dd3120dc088b22c5cfb4ce /test
parente0accce581bbc83458cf8d720801f3480e62a36b (diff)
parentf3b286c60f4f88509947be71d5d5cb8750f276b5 (diff)
downloadrspamd-f8718a1191753a141a63ee716aad27df17562df2.tar.gz
rspamd-f8718a1191753a141a63ee716aad27df17562df2.zip
Merge pull request #847 from fatalbanana/mmtest
[Test] Add test for multimap URL maps & filters
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/102_multimap.robot59
-rw-r--r--test/functional/configs/multimap.conf30
-rw-r--r--test/functional/messages/url1.eml3
-rw-r--r--test/functional/messages/url2.eml3
-rw-r--r--test/functional/messages/url3.eml3
-rw-r--r--test/functional/messages/url4.eml4
6 files changed, 102 insertions, 0 deletions
diff --git a/test/functional/cases/102_multimap.robot b/test/functional/cases/102_multimap.robot
index 03db8c854..36fdb0166 100644
--- a/test/functional/cases/102_multimap.robot
+++ b/test/functional/cases/102_multimap.robot
@@ -11,6 +11,11 @@ ${MESSAGE} ${TESTDIR}/messages/spam_message.eml
${UTF_MESSAGE} ${TESTDIR}/messages/utf.eml
${REDIS_SCOPE} Suite
${RSPAMD_SCOPE} Suite
+${URL1} ${TESTDIR}/messages/url1.eml
+${URL2} ${TESTDIR}/messages/url2.eml
+${URL3} ${TESTDIR}/messages/url3.eml
+${URL4} ${TESTDIR}/messages/url4.eml
+${URL5} ${TESTDIR}/messages/url5.eml
*** Test Cases ***
MAP - DNSBL HIT
@@ -142,6 +147,60 @@ MAP - REDIS - FROM MISS
${result} = Scan Message With Rspamc ${MESSAGE} --from user@other.com
Check Rspamc ${result} REDIS_FROMADDR inverse=1
+MAP - REDIS - URL TLD - HIT
+ Redis HSET hostname example.com ${EMPTY}
+ ${result} = Scan Message With Rspamc ${URL1}
+ Check Rspamc ${result} REDIS_URL_TLD
+
+MAP - REDIS - URL TLD - MISS
+ ${result} = Scan Message With Rspamc ${URL2}
+ Check Rspamc ${result} REDIS_URL_TLD inverse=1
+
+MAP - REDIS - URL RE FULL - HIT
+ Redis HSET fullurlre html ${EMPTY}
+ ${result} = Scan Message With Rspamc ${URL2}
+ Check Rspamc ${result} REDIS_URL_RE_FULL
+
+MAP - REDIS - URL RE FULL - MISS
+ ${result} = Scan Message With Rspamc ${URL1}
+ Check Rspamc ${result} REDIS_URL_RE_FULL inverse=1
+
+MAP - REDIS - URL FULL - HIT
+ Redis HSET fullurl https://www.example.com/foo?a=b ${EMPTY}
+ ${result} = Scan Message With Rspamc ${URL1}
+ Check Rspamc ${result} REDIS_URL_FULL
+
+MAP - REDIS - URL FULL - MISS
+ ${result} = Scan Message With Rspamc ${URL2}
+ Check Rspamc ${result} REDIS_URL_FULL inverse=1
+
+MAP - REDIS - URL PHISHED - HIT
+ Redis HSET phishedurl www.rspamd.com ${EMPTY}
+ ${result} = Scan Message With Rspamc ${URL3}
+ Check Rspamc ${result} REDIS_URL_PHISHED
+
+MAP - REDIS - URL PHISHED - MISS
+ ${result} = Scan Message With Rspamc ${URL4}
+ Check Rspamc ${result} REDIS_URL_PHISHED inverse=1
+
+MAP - REDIS - URL PLAIN REGEX - HIT
+ Redis HSET urlre www ${EMPTY}
+ ${result} = Scan Message With Rspamc ${URL3}
+ Check Rspamc ${result} REDIS_URL_RE_PLAIN
+
+MAP - REDIS - URL PLAIN REGEX - MISS
+ ${result} = Scan Message With Rspamc ${URL4}
+ Check Rspamc ${result} REDIS_URL_RE_PLAIN inverse=1
+
+MAP - REDIS - URL TLD REGEX - HIT
+ Redis HSET tldre net ${EMPTY}
+ ${result} = Scan Message With Rspamc ${URL5}
+ Check Rspamc ${result} REDIS_URL_RE_TLD
+
+MAP - REDIS - URL TLD REGEX - MISS
+ ${result} = Scan Message With Rspamc ${URL4}
+ Check Rspamc ${result} REDIS_URL_RE_TLD inverse=1
+
*** Keywords ***
Multimap Setup
${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/multimap.conf
diff --git a/test/functional/configs/multimap.conf b/test/functional/configs/multimap.conf
index 7c75c7a91..e993b1f7d 100644
--- a/test/functional/configs/multimap.conf
+++ b/test/functional/configs/multimap.conf
@@ -62,4 +62,34 @@ multimap {
filter = "email:addr";
map = "redis://emailaddr";
}
+ REDIS_URL_TLD {
+ type = "url";
+ map = "redis://hostname";
+ filter = "tld";
+ }
+ REDIS_URL_RE_FULL {
+ type = "url";
+ map = "redis://fullurlre";
+ filter = "full:regexp:/(html)$/";
+ }
+ REDIS_URL_FULL {
+ type = "url";
+ map = "redis://fullurl";
+ filter = "full";
+ }
+ REDIS_URL_PHISHED {
+ type = "url";
+ map = "redis://phishedurl";
+ filter = "is_phished";
+ }
+ REDIS_URL_RE_TLD {
+ type = "url";
+ map = "redis://tldre";
+ filter = "tld:regexp:/(net)$/";
+ }
+ REDIS_URL_RE_PLAIN {
+ type = "url";
+ map = "redis://urlre";
+ filter = "regexp:/^(www)/";
+ }
}
diff --git a/test/functional/messages/url1.eml b/test/functional/messages/url1.eml
new file mode 100644
index 000000000..42361ae2d
--- /dev/null
+++ b/test/functional/messages/url1.eml
@@ -0,0 +1,3 @@
+Content-Type: text/plain
+
+hello https://www.example.com/foo?a=b hello
diff --git a/test/functional/messages/url2.eml b/test/functional/messages/url2.eml
new file mode 100644
index 000000000..bfa72535f
--- /dev/null
+++ b/test/functional/messages/url2.eml
@@ -0,0 +1,3 @@
+Content-Type: text/plain
+
+hello https://www.rspamd.com/doc/modules/multimap.html hello
diff --git a/test/functional/messages/url3.eml b/test/functional/messages/url3.eml
new file mode 100644
index 000000000..eabfd983b
--- /dev/null
+++ b/test/functional/messages/url3.eml
@@ -0,0 +1,3 @@
+Content-Type: text/html
+
+hello <a href="https://www.rspamd.com/doc/modules/multimap.html">https://www.bank.com</a> hello
diff --git a/test/functional/messages/url4.eml b/test/functional/messages/url4.eml
new file mode 100644
index 000000000..eba4f873e
--- /dev/null
+++ b/test/functional/messages/url4.eml
@@ -0,0 +1,4 @@
+Content-Type: text/html
+
+hello <a href="https://example.com/">https://rspamd.tk</a> hello
+hello <a href="https://rspamd.com/doc/modules/multimap.html">https://rspamd.com</a> hello