commit 04b5bfd: Add tests for key cache invalidation

John McKay adenosine3p at gmail.com
Mon Feb 4 14:35:09 UTC 2019


Author: John McKay
Date: 2019-01-21 04:09:09 +0000
URL: https://github.com/rspamd/rspamd/commit/04b5bfde88920f472516ebae5172b232e7ca37a0

Add tests for key cache invalidation

---
 .../{003_eddsa.robot => 004_invalidate_key.robot}  | 32 +++++++++++++++-------
 .../dkim_signing/{eddsa.conf => invalidate.conf}   |  2 +-
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/test/functional/cases/131_dkim_signing/003_eddsa.robot b/test/functional/cases/131_dkim_signing/004_invalidate_key.robot
similarity index 54%
copy from test/functional/cases/131_dkim_signing/003_eddsa.robot
copy to test/functional/cases/131_dkim_signing/004_invalidate_key.robot
index ea2fe03be..08a3ac623 100644
--- a/test/functional/cases/131_dkim_signing/003_eddsa.robot
+++ b/test/functional/cases/131_dkim_signing/004_invalidate_key.robot
@@ -1,6 +1,6 @@
 *** Settings ***
-Suite Setup     DKIM Signing Setup
-Suite Teardown  DKIM Signing Teardown
+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
@@ -8,7 +8,6 @@ Variables       ${TESTDIR}/lib/vars.py
 *** Variables ***
 ${CONFIG}       ${TESTDIR}/configs/plugins.conf
 ${MESSAGE}      ${TESTDIR}/messages/dmarc/fail_none.eml
-${MESSAGE_FAIL}      ${TESTDIR}/messages/dmarc/fail_none1.eml
 ${REDIS_SCOPE}  Suite
 ${RSPAMD_SCOPE}  Suite
 ${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
@@ -19,21 +18,34 @@ TEST SIGNED
   Check Rspamc  ${result}  DKIM-Signature:
   Should Contain  ${result.stdout}  DKIM_SIGNED
 
-TEST NOT SIGNED - USERNAME WRONG DOMAIN
-  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -u  bob at example.tk
+TEST NOT SIGNED - MISSING KEY
+  [Setup] 	Delete Key
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -u  bob at cacophony.za.org
   Check Rspamc  ${result}  DKIM-Signature:  inverse=1
   Should Not Contain  ${result.stdout}  DKIM_SIGNED
 
-TEST NOT SIGNED - USERNAME WRONG PUBKEY
-  ${result} =  Scan Message With Rspamc  ${MESSAGE_FAIL}  -u  bob at invalid.za.org
+TEST NOT SIGNED - KEY NO LONGER MATCHES
+  [Setup]	Move Key
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -u  bob at cacophony.za.org
   Check Rspamc  ${result}  DKIM-Signature:  inverse=1
   Should Not Contain  ${result.stdout}  DKIM_SIGNED
 
 *** Keywords ***
-DKIM Signing Setup
-  ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/dkim_signing/eddsa.conf
+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
 
-DKIM Signing Teardown
+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/eddsa.conf b/test/functional/configs/dkim_signing/invalidate.conf
similarity index 67%
copy from test/functional/configs/dkim_signing/eddsa.conf
copy to test/functional/configs/dkim_signing/invalidate.conf
index 1a93c9e0b..48b1cec16 100644
--- a/test/functional/configs/dkim_signing/eddsa.conf
+++ b/test/functional/configs/dkim_signing/invalidate.conf
@@ -1,5 +1,5 @@
 dkim_signing {
-  path = "${TESTDIR}/configs/dkim-eddsa.key";
+  path = "${KEY_DIR}/dkim-eddsa.key";
   selector = "eddsa";
   check_pubkey = true;
   allow_pubkey_mismatch = false;


More information about the Commits mailing list