]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add test for multimap URL maps & filters 847/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 15 Aug 2016 09:43:46 +0000 (10:43 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 15 Aug 2016 09:43:46 +0000 (10:43 +0100)
test/functional/cases/102_multimap.robot
test/functional/configs/multimap.conf
test/functional/messages/url1.eml [new file with mode: 0644]
test/functional/messages/url2.eml [new file with mode: 0644]
test/functional/messages/url3.eml [new file with mode: 0644]
test/functional/messages/url4.eml [new file with mode: 0644]

index 03db8c8541e7282b3e709efa5b601318f5452b75..36fdb0166c526327a332ae4dcb9984ca1b7f9e0b 100644 (file)
@@ -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
index 7c75c7a912a844442704d53570f5e64d49652739..e993b1f7de8ff350ea4c8e3d7afb76bece9c99c1 100644 (file)
@@ -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 (file)
index 0000000..42361ae
--- /dev/null
@@ -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 (file)
index 0000000..bfa7253
--- /dev/null
@@ -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 (file)
index 0000000..eabfd98
--- /dev/null
@@ -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 (file)
index 0000000..eba4f87
--- /dev/null
@@ -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