From: Vsevolod Stakhov Date: Tue, 14 May 2019 09:53:17 +0000 (+0100) Subject: [Test] Add some tests for arc signing X-Git-Tag: 2.0~905 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=479e97e8c044d3bc2f711c25a276a9ea5aec567a;p=rspamd.git [Test] Add some tests for arc signing --- diff --git a/test/functional/cases/320_arc_signing/001_simple.robot b/test/functional/cases/320_arc_signing/001_simple.robot new file mode 100644 index 000000000..73623574b --- /dev/null +++ b/test/functional/cases/320_arc_signing/001_simple.robot @@ -0,0 +1,40 @@ +*** Settings *** +Suite Setup ARC Signing Setup +Suite Teardown ARC Signing 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 +${MESSAGE_FAIL} ${TESTDIR}/messages/dmarc/fail_none1.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 + Should Contain ${result.stdout} ARC_SIGNED + +TEST SIGNED HTTP HEADERS + ${result} = Scan Message With Rspamc ${MESSAGE} -u bob@cacophony.za.org --header=PerformArcSign:yes --header=DkimDomain:cacophony.za.org --header=DkimSelector:dkim --header=DkimPrivateKey:MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANe3EETkiI1Exyrb+VzbMSt90K8MXJA0GcyNs6MFCs9JPaTh90Zu2l7ki7m5LTUx6350AR/3hcvwjSHCZjD6fvQ8/zfjN8kaLZ6DAaqtqSlpawIM+8glkuTEkIkpBED/OtDrba4Rd29iLFVuwQZXDtTjAAZKZPmtTZ5TXLrcCU6VAgMBAAECgYEA1BFvmBsIN8Gu/+6kNupya2xUNVM0yLu/xT5lpNV3LBO325oejAq8+d87kkl/LTW3a2jGFlQ0ICuLw+2mo24QUWRyv8if3oeBMlnLqHE+6wNjFVqo5sOjKzjO363xSXwXNUrBT7jDhnZcDN8w3/FecYKjifGTVtUs1SLsYwhlc8ECQQDuCRymLZQ/imPn5eFVIydwUzg8ptZlvoA7bfIxUL9BQRX33s59kLCilA0tTed8Dd+GnxsT93XOj1ApIfBwmTSlAkEA5/63PDsN7fH+WInqVD8nU07M9S8LcGDlPbVVBr2S2I78/iwrSDAYtbkU2vEbhFK/JuKNML2j8OkzV3v1QulfMQJBALDzhx+l/HHr3+8RPhx7QKNIyiKUaAdEwbDsP8IXY8YPq1QThu9jM1v4sX7/TdkzuvoppwiFykbe1NlvCH279p0CQCmTg4Ee0DtBcCSr6rvYaZLLf329RZ6JLuwlMCy6ErQOxBZFEiiovfTrS2qFZToMnkc4uLbwdY36LQJTq7unGTECQCCok8LzBeZtAw+TJofpOM3F2Rlm2qXiBVBeubhRedsiljG0hpvvLJBMppnQ6r27p5Jk39SmaTRkxEKrxPWWLNM= + Should Contain ${result.stdout} ARC_SIGNED + +TEST NOT SIGNED - USERNAME WRONG DOMAIN + ${result} = Scan Message With Rspamc ${MESSAGE} -u bob@example.tk + Should Not Contain ${result.stdout} ARC_SIGNED + +TEST NOT SIGNED - USERNAME WRONG PUBKEY + ${result} = Scan Message With Rspamc ${MESSAGE_FAIL} -u bob@invalid.za.org + Should Not Contain ${result.stdout} ARC_SIGNED + +*** Keywords *** +ARC Signing Setup + ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/arc_signing/simple.conf + Set Suite Variable ${PLUGIN_CONFIG} + Generic Setup PLUGIN_CONFIG + +ARC Signing Teardown + Normal Teardown diff --git a/test/functional/cases/320_arc_signing/002_redis.robot b/test/functional/cases/320_arc_signing/002_redis.robot new file mode 100644 index 000000000..2fde59164 --- /dev/null +++ b/test/functional/cases/320_arc_signing/002_redis.robot @@ -0,0 +1,36 @@ +*** Settings *** +Suite Setup ARC Signing Setup +Suite Teardown ARC Signing 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 + Should Contain ${result.stdout} ARC_SIGNED + +TEST NOT SIGNED - USERNAME WRONG DOMAIN + ${result} = Scan Message With Rspamc ${MESSAGE} -u bob@example.tk + Should Not Contain ${result.stdout} ARC_SIGNED + +*** Keywords *** +ARC Signing Setup + ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/arc_signing/redis.conf + Set Suite Variable ${PLUGIN_CONFIG} + Generic Setup PLUGIN_CONFIG + Run Redis + Redis HSET TEST_DKIM_SELECTORS cacophony.za.org arc + ${key} = Get File ${TESTDIR}/configs/dkim.key + Redis HSET TEST_DKIM_KEYS arc.cacophony.za.org ${key} + +ARC Signing Teardown + Normal Teardown + Shutdown Process With Children ${REDIS_PID} diff --git a/test/functional/configs/arc_signing/redis.conf b/test/functional/configs/arc_signing/redis.conf new file mode 100644 index 000000000..b2a9aa134 --- /dev/null +++ b/test/functional/configs/arc_signing/redis.conf @@ -0,0 +1,8 @@ +arc { + use_redis = true; + key_prefix = "TEST_DKIM_KEYS"; + selector_prefix = "TEST_DKIM_SELECTORS"; +} +redis { + servers = "${REDIS_ADDR}:${REDIS_PORT}"; +} diff --git a/test/functional/configs/arc_signing/simple.conf b/test/functional/configs/arc_signing/simple.conf new file mode 100644 index 000000000..5807d7346 --- /dev/null +++ b/test/functional/configs/arc_signing/simple.conf @@ -0,0 +1,8 @@ +arc { + path = "${TESTDIR}/configs/dkim.key"; + check_pubkey = true; + allow_pubkey_mismatch = false; + selector = "dkim"; + use_http_headers = true; + allow_headers_fallback = true; +}