]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Add tests for DMARC 884/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 23 Aug 2016 15:05:28 +0000 (17:05 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 23 Aug 2016 15:05:28 +0000 (17:05 +0200)
16 files changed:
test/functional/cases/102_multimap.robot
test/functional/cases/105_mimetypes.robot
test/functional/cases/115_dmarc.robot [new file with mode: 0644]
test/functional/cases/135_spamassassin.robot
test/functional/configs/dmarc.conf [new file with mode: 0644]
test/functional/configs/plugins.conf
test/functional/messages/dmarc/fail_none.eml [new file with mode: 0644]
test/functional/messages/dmarc/fail_quarantine.eml [new file with mode: 0644]
test/functional/messages/dmarc/fail_reject.eml [new file with mode: 0644]
test/functional/messages/dmarc/onsubdomain_fail.eml [new file with mode: 0644]
test/functional/messages/dmarc/onsubdomain_fail_alignment.eml [new file with mode: 0644]
test/functional/messages/dmarc/onsubdomain_pass_relaxed.eml [new file with mode: 0644]
test/functional/messages/dmarc/pass_none.eml [new file with mode: 0644]
test/functional/messages/dmarc/subdomain_fail_none.eml [new file with mode: 0644]
test/functional/messages/dmarc/subdomain_fail_quarantine.eml [new file with mode: 0644]
test/functional/messages/dmarc/subdomain_fail_reject.eml [new file with mode: 0644]

index abe79f51289d220ffeb0493d7ee9d51ea3d4b852..22551cba84e10818c64a9049188145419418ec30 100644 (file)
@@ -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
index 18eac62892cd2780197b50e7946bd15054e010ee..8e124e3f732f2e1e2c9641b2958a2c071a45117c 100644 (file)
@@ -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 (file)
index 0000000..f2a93db
--- /dev/null
@@ -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
index 2e5c0bb59e15eb1e897d150bc53af1d2d8610c99..d1901068c33cb591f20d565260829ebc3d404c1f 100644 (file)
@@ -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 (file)
index 0000000..ddfc1ac
--- /dev/null
@@ -0,0 +1 @@
+dmarc { }
index 2beb7b764fe708a666c8672d92aafab6e1b77073..1e03090829d1a168479352acf78fe7cd624989ca 100644 (file)
@@ -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 (file)
index 0000000..1dc97c2
--- /dev/null
@@ -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 (file)
index 0000000..6af9d21
--- /dev/null
@@ -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 (file)
index 0000000..014d20c
--- /dev/null
@@ -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 (file)
index 0000000..51e1535
--- /dev/null
@@ -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 (file)
index 0000000..d144337
--- /dev/null
@@ -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 (file)
index 0000000..714c560
--- /dev/null
@@ -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 (file)
index 0000000..e29e6a5
--- /dev/null
@@ -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 (file)
index 0000000..7dc0d64
--- /dev/null
@@ -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 (file)
index 0000000..366ba79
--- /dev/null
@@ -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 (file)
index 0000000..697cf57
--- /dev/null
@@ -0,0 +1,3 @@
+From: Rspamd <foo@foo.cacophony.za.org>
+
+hello