]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add tests for key cache invalidation
authorJohn McKay <adenosine3p@gmail.com>
Mon, 21 Jan 2019 04:09:09 +0000 (04:09 +0000)
committerJohn McKay <adenosine3p@gmail.com>
Sat, 2 Feb 2019 05:30:00 +0000 (05:30 +0000)
test/functional/cases/131_dkim_signing/004_invalidate_key.robot [new file with mode: 0644]
test/functional/configs/dkim_signing/invalidate.conf [new file with mode: 0644]

diff --git a/test/functional/cases/131_dkim_signing/004_invalidate_key.robot b/test/functional/cases/131_dkim_signing/004_invalidate_key.robot
new file mode 100644 (file)
index 0000000..08a3ac6
--- /dev/null
@@ -0,0 +1,51 @@
+*** Settings ***
+Suite Setup     Key Invalidation Setup
+Suite Teardown  Key Invalidation 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/dmarc/fail_none.eml
+${REDIS_SCOPE}  Suite
+${RSPAMD_SCOPE}  Suite
+${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
+
+*** Test Cases ***
+TEST SIGNED
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -u  bob@cacophony.za.org
+  Check Rspamc  ${result}  DKIM-Signature:
+  Should Contain  ${result.stdout}  DKIM_SIGNED
+
+TEST NOT SIGNED - MISSING KEY
+  [Setup]      Delete Key
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -u  bob@cacophony.za.org
+  Check Rspamc  ${result}  DKIM-Signature:  inverse=1
+  Should Not Contain  ${result.stdout}  DKIM_SIGNED
+
+TEST NOT SIGNED - KEY NO LONGER MATCHES
+  [Setup]      Move Key
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -u  bob@cacophony.za.org
+  Check Rspamc  ${result}  DKIM-Signature:  inverse=1
+  Should Not Contain  ${result.stdout}  DKIM_SIGNED
+
+*** Keywords ***
+Key Invalidation Setup
+  ${key_dir}  Make Temporary Directory
+  Set Suite Variable  ${KEY_DIR}  ${key_dir}
+  Copy File  ${TESTDIR}/configs/dkim-eddsa.key  ${KEY_DIR}/dkim-eddsa.key
+  ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/dkim_signing/invalidate.conf
+  Set Suite Variable  ${PLUGIN_CONFIG}
+  Generic Setup  PLUGIN_CONFIG
+
+Delete Key
+  Remove File  ${KEY_DIR}/dkim-eddsa.key
+
+Move Key
+  Copy File  ${TESTDIR}/configs/dkim.key  ${KEY_DIR}/dkim-eddsa.key
+  Set Modified Time  ${KEY_DIR}/dkim-eddsa.key  NOW + 3s
+
+Key Invalidation Teardown
+  Cleanup Temporary Directory  ${KEY_DIR}
+  Normal Teardown
diff --git a/test/functional/configs/dkim_signing/invalidate.conf b/test/functional/configs/dkim_signing/invalidate.conf
new file mode 100644 (file)
index 0000000..48b1cec
--- /dev/null
@@ -0,0 +1,6 @@
+dkim_signing {
+  path = "${KEY_DIR}/dkim-eddsa.key";
+  selector = "eddsa";
+  check_pubkey = true;
+  allow_pubkey_mismatch = false;
+}