aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-08-23 17:05:28 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-08-23 17:05:28 +0200
commitd003de1435f27c31de78d975ee54e07e7c0c2d20 (patch)
tree66579c9dc1406bdd5fe4f739f73ac24aec27c885 /test
parent305de55ddaf9cd50e77dab247f433bf657f1c98d (diff)
downloadrspamd-d003de1435f27c31de78d975ee54e07e7c0c2d20.tar.gz
rspamd-d003de1435f27c31de78d975ee54e07e7c0c2d20.zip
[Test] Add tests for DMARC
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/102_multimap.robot1
-rw-r--r--test/functional/cases/105_mimetypes.robot1
-rw-r--r--test/functional/cases/115_dmarc.robot74
-rw-r--r--test/functional/cases/135_spamassassin.robot1
-rw-r--r--test/functional/configs/dmarc.conf1
-rw-r--r--test/functional/configs/plugins.conf2
-rw-r--r--test/functional/messages/dmarc/fail_none.eml3
-rw-r--r--test/functional/messages/dmarc/fail_quarantine.eml3
-rw-r--r--test/functional/messages/dmarc/fail_reject.eml3
-rw-r--r--test/functional/messages/dmarc/onsubdomain_fail.eml3
-rw-r--r--test/functional/messages/dmarc/onsubdomain_fail_alignment.eml11
-rw-r--r--test/functional/messages/dmarc/onsubdomain_pass_relaxed.eml11
-rw-r--r--test/functional/messages/dmarc/pass_none.eml17
-rw-r--r--test/functional/messages/dmarc/subdomain_fail_none.eml3
-rw-r--r--test/functional/messages/dmarc/subdomain_fail_quarantine.eml3
-rw-r--r--test/functional/messages/dmarc/subdomain_fail_reject.eml3
16 files changed, 139 insertions, 1 deletions
diff --git a/test/functional/cases/102_multimap.robot b/test/functional/cases/102_multimap.robot
index abe79f512..22551cba8 100644
--- a/test/functional/cases/102_multimap.robot
+++ b/test/functional/cases/102_multimap.robot
@@ -16,6 +16,7 @@ ${URL2} ${TESTDIR}/messages/url2.eml
${URL3} ${TESTDIR}/messages/url3.eml
${URL4} ${TESTDIR}/messages/url4.eml
${URL5} ${TESTDIR}/messages/url5.eml
+${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat
*** Test Cases ***
MAP - DNSBL HIT
diff --git a/test/functional/cases/105_mimetypes.robot b/test/functional/cases/105_mimetypes.robot
index 18eac6289..8e124e3f7 100644
--- a/test/functional/cases/105_mimetypes.robot
+++ b/test/functional/cases/105_mimetypes.robot
@@ -8,6 +8,7 @@ Variables ${TESTDIR}/lib/vars.py
*** Variables ***
${CONFIG} ${TESTDIR}/configs/plugins.conf
${RSPAMD_SCOPE} Suite
+${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat
*** Test Cases ***
Zip
diff --git a/test/functional/cases/115_dmarc.robot b/test/functional/cases/115_dmarc.robot
new file mode 100644
index 000000000..f2a93db02
--- /dev/null
+++ b/test/functional/cases/115_dmarc.robot
@@ -0,0 +1,74 @@
+*** Settings ***
+Suite Setup DMARC 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
+${URL_TLD} ${TESTDIR}/../../contrib/publicsuffix/effective_tld_names.dat
+
+*** Test Cases ***
+DMARC NONE PASS DKIM
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/pass_none.eml
+ Check Rspamc ${result} DMARC_POLICY_ALLOW
+
+DMARC NONE PASS SPF
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/fail_none.eml
+ ... -i 212.47.245.199 --from foo@rspamd.tk
+ Check Rspamc ${result} DMARC_POLICY_ALLOW
+
+DMARC NONE FAIL
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/fail_none.eml
+ Check Rspamc ${result} DMARC_POLICY_SOFTFAIL
+
+DMARC REJECT FAIL
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/fail_reject.eml
+ Check Rspamc ${result} DMARC_POLICY_REJECT
+
+DMARC QUARANTINE FAIL
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/fail_quarantine.eml
+ Check Rspamc ${result} DMARC_POLICY_QUARANTINE
+
+DMARC SP NONE FAIL
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/subdomain_fail_none.eml
+ Check Rspamc ${result} DMARC_POLICY_SOFTFAIL
+
+DMARC SP REJECT FAIL
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/subdomain_fail_reject.eml
+ Check Rspamc ${result} DMARC_POLICY_REJECT
+
+DMARC SP QUARANTINE FAIL
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/subdomain_fail_quarantine.eml
+ Check Rspamc ${result} DMARC_POLICY_QUARANTINE
+
+DMARC SUBDOMAIN FAIL DKIM STRICT ALIGNMENT
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/onsubdomain_fail_alignment.eml
+ Check Rspamc ${result} DMARC_POLICY_REJECT
+
+DMARC SUBDOMAIN PASS DKIM RELAXED ALIGNMENT
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/onsubdomain_pass_relaxed.eml
+ Check Rspamc ${result} DMARC_POLICY_ALLOW
+
+DMARC SUBDOMAIN PASS SPF STRICT ALIGNMENT
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/onsubdomain_fail_alignment.eml
+ ... -i 37.48.67.26 --from foo@yo.mom.za.org
+ Check Rspamc ${result} DMARC_POLICY_ALLOW
+
+DMARC SUBDOMAIN FAIL SPF STRICT ALIGNMENT
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/onsubdomain_fail_alignment.eml
+ ... -i 37.48.67.26 --from foo@mom.za.org
+ Check Rspamc ${result} DMARC_POLICY_REJECT
+
+DMARC SUBDOMAIN PASS SPF RELAXED ALIGNMENT
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/dmarc/onsubdomain_fail.eml
+ ... -i 37.48.67.26 --from foo@mom.za.org
+ Check Rspamc ${result} DMARC_POLICY_ALLOW
+
+*** Keywords ***
+DMARC Setup
+ ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/dmarc.conf
+ Set Suite Variable ${PLUGIN_CONFIG}
+ Generic Setup PLUGIN_CONFIG
diff --git a/test/functional/cases/135_spamassassin.robot b/test/functional/cases/135_spamassassin.robot
index 2e5c0bb59..d1901068c 100644
--- a/test/functional/cases/135_spamassassin.robot
+++ b/test/functional/cases/135_spamassassin.robot
@@ -8,6 +8,7 @@ Variables ${TESTDIR}/lib/vars.py
*** Variables ***
${CONFIG} ${TESTDIR}/configs/plugins.conf
${RSPAMD_SCOPE} Suite
+${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat
*** Test Cases ***
Freemail Scan
diff --git a/test/functional/configs/dmarc.conf b/test/functional/configs/dmarc.conf
new file mode 100644
index 000000000..ddfc1ac61
--- /dev/null
+++ b/test/functional/configs/dmarc.conf
@@ -0,0 +1 @@
+dmarc { }
diff --git a/test/functional/configs/plugins.conf b/test/functional/configs/plugins.conf
index 2beb7b764..1e0309082 100644
--- a/test/functional/configs/plugins.conf
+++ b/test/functional/configs/plugins.conf
@@ -1,6 +1,6 @@
options = {
filters = ["spf", "dkim", "regexp"]
- url_tld = "${TESTDIR}/../lua/unit/test_tld.dat"
+ url_tld = "${URL_TLD}"
pidfile = "${TMPDIR}/rspamd.pid"
lua_path = "${TESTDIR}/../../contrib/lua-fun/?.lua"
}
diff --git a/test/functional/messages/dmarc/fail_none.eml b/test/functional/messages/dmarc/fail_none.eml
new file mode 100644
index 000000000..1dc97c2ea
--- /dev/null
+++ b/test/functional/messages/dmarc/fail_none.eml
@@ -0,0 +1,3 @@
+From: Rspamd <foo@rspamd.tk>
+
+hello
diff --git a/test/functional/messages/dmarc/fail_quarantine.eml b/test/functional/messages/dmarc/fail_quarantine.eml
new file mode 100644
index 000000000..6af9d2186
--- /dev/null
+++ b/test/functional/messages/dmarc/fail_quarantine.eml
@@ -0,0 +1,3 @@
+From: Rspamd <foo@quarantine.rspamd.tk>
+
+hello
diff --git a/test/functional/messages/dmarc/fail_reject.eml b/test/functional/messages/dmarc/fail_reject.eml
new file mode 100644
index 000000000..014d20c06
--- /dev/null
+++ b/test/functional/messages/dmarc/fail_reject.eml
@@ -0,0 +1,3 @@
+From: Rspamd <foo@reject.rspamd.tk>
+
+hello
diff --git a/test/functional/messages/dmarc/onsubdomain_fail.eml b/test/functional/messages/dmarc/onsubdomain_fail.eml
new file mode 100644
index 000000000..51e15352a
--- /dev/null
+++ b/test/functional/messages/dmarc/onsubdomain_fail.eml
@@ -0,0 +1,3 @@
+From: <koos@my.mom.za.org>
+
+hello
diff --git a/test/functional/messages/dmarc/onsubdomain_fail_alignment.eml b/test/functional/messages/dmarc/onsubdomain_fail_alignment.eml
new file mode 100644
index 000000000..d1443373e
--- /dev/null
+++ b/test/functional/messages/dmarc/onsubdomain_fail_alignment.eml
@@ -0,0 +1,11 @@
+From: <koos@yo.mom.za.org>
+Subject: yo mom
+Content-type: text/plain
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mom.za.org; s=testdkim;
+ t=1471961268; h=from:subject:content-type;
+ bh=BIB4FUu24DrAHudZNxS2O9+aq+jb0j8fPGz27CAMcyM=; b=LNrJ+02t42FSzzN0La6BSI4zN5m/pOLqjSSNHoLTfz7ewDrH9Fc27VJ4W1c+X18C40htFp
+ RuGsjH1XyirwLAd+gDCB12ehuO2uIGWtKyi1EWwivqYs6ACzRvcOMvNM3m/YfJyqZRBWDC
+ C6wcJsJ2gbRZIGVbn4VdTVm6Kbhmj/M=
+
+yo mom deserves respect
+
diff --git a/test/functional/messages/dmarc/onsubdomain_pass_relaxed.eml b/test/functional/messages/dmarc/onsubdomain_pass_relaxed.eml
new file mode 100644
index 000000000..714c5604b
--- /dev/null
+++ b/test/functional/messages/dmarc/onsubdomain_pass_relaxed.eml
@@ -0,0 +1,11 @@
+From: <koos@my.mom.za.org>
+Subject: my mom
+Content-type: text/plain
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mom.za.org; s=testdkim;
+ t=1471961323; h=from:subject:content-type;
+ bh=7nTyaR2hZHHEh0TrHDN2UloE2SBtWOqNvwm8wB4BI+M=; b=S/CEbLcr3duA/2rwNAcX03T1KYz4YXI8sH+OQ1YX1+y4Pxi4MjF3cqstLX4jKyrjbBHSAJ
+ mC9QT9vC+4R8syDXZnJw6gChLsR2NymCPp3nbbukmgsNustzyIu7wg4amwZ1yx/m4Ihwvv
+ NfSaAZcJS4tAgtOHmFzkt2zPD4y9+OU=
+
+my mom deserves respect
+
diff --git a/test/functional/messages/dmarc/pass_none.eml b/test/functional/messages/dmarc/pass_none.eml
new file mode 100644
index 000000000..e29e6a5de
--- /dev/null
+++ b/test/functional/messages/dmarc/pass_none.eml
@@ -0,0 +1,17 @@
+Date: Tue, 09 Aug 2016 10:01:27 +0200
+Message-ID: <20160809100127@rspamd.tk>
+From: Rspamd <foo@rspamd.tk>
+To: foo@rspamd.tk
+Subject: hello
+Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes
+MIME-Version: 1.0
+Content-Disposition: inline
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rspamd.tk; s=testdkim;
+ t=1470729879; h=from:subject:date:message-id:to:mime-version:content-type;
+ bh=7HkRgYnNru3SR2EWfgWU8yhM0MOH6ZZrPoEIgNIh8wc=;
+ b=kTIV4jcgv9sWFh2JFrS/+PcNxiloituqjmHHqeJOTfa+/9C+Er8BjnMysTJyYVq36Gnv0OZDgLr3Yy4YP5Lzbt1M9ZdN5cJqO7yn1N7wyaGfkt++b09rIYBy5Dkk7OWyP3cDThqDzv8C9heSvqBSEsirFsbt3Wx2g/hWiJlnjew=
+
+
+hello
+
+
diff --git a/test/functional/messages/dmarc/subdomain_fail_none.eml b/test/functional/messages/dmarc/subdomain_fail_none.eml
new file mode 100644
index 000000000..7dc0d64c9
--- /dev/null
+++ b/test/functional/messages/dmarc/subdomain_fail_none.eml
@@ -0,0 +1,3 @@
+From: Rspamd <foo@foo.yoni.za.org>
+
+hello
diff --git a/test/functional/messages/dmarc/subdomain_fail_quarantine.eml b/test/functional/messages/dmarc/subdomain_fail_quarantine.eml
new file mode 100644
index 000000000..366ba79c6
--- /dev/null
+++ b/test/functional/messages/dmarc/subdomain_fail_quarantine.eml
@@ -0,0 +1,3 @@
+From: Rspamd <foo@foo.yoni.za.net>
+
+hello
diff --git a/test/functional/messages/dmarc/subdomain_fail_reject.eml b/test/functional/messages/dmarc/subdomain_fail_reject.eml
new file mode 100644
index 000000000..697cf5705
--- /dev/null
+++ b/test/functional/messages/dmarc/subdomain_fail_reject.eml
@@ -0,0 +1,3 @@
+From: Rspamd <foo@foo.cacophony.za.org>
+
+hello