]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add DKIM sign + verify tests 792/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 2 Aug 2016 18:22:53 +0000 (19:22 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 2 Aug 2016 20:16:56 +0000 (21:16 +0100)
test/functional/cases/130_dkim.robot [new file with mode: 0644]
test/functional/configs/dkim.conf [new file with mode: 0644]
test/functional/configs/dkim.key [new file with mode: 0644]

diff --git a/test/functional/cases/130_dkim.robot b/test/functional/cases/130_dkim.robot
new file mode 100644 (file)
index 0000000..88ce5eb
--- /dev/null
@@ -0,0 +1,24 @@
+*** Settings ***
+Suite Setup     Generic Setup
+Suite Teardown  Generic Teardown
+Library         ${TESTDIR}/lib/rspamd.py
+Resource        ${TESTDIR}/lib/rspamd.robot
+Variables       ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG}       ${TESTDIR}/configs/dkim.conf
+${RSPAMD_SCOPE}  Suite
+
+*** Test Cases ***
+DKIM Sign
+  Set Suite Variable  ${RAN_SIGNTEST}  0
+  ${result} =  Scan Message With Rspamc  ${TESTDIR}/messages/spam_message.eml  --mime  --header=dodkim=1
+  Check Rspamc  ${result}  DKIM-Signature
+  Set Suite Variable  ${SIGNED_MESSAGE}  ${TMPDIR}/dkim_sign_test.eml
+  Create File  ${SIGNED_MESSAGE}  ${result.stdout}
+  Set Suite Variable  ${RAN_SIGNTEST}  1
+
+DKIM Self Verify
+  Run Keyword If  ${RAN_SIGNTEST} == 0  Fail  "Sign test was not run"
+  ${result} =  Scan Message With Rspamc  ${SIGNED_MESSAGE}
+  Check Rspamc  ${result}  R_DKIM_ALLOW
diff --git a/test/functional/configs/dkim.conf b/test/functional/configs/dkim.conf
new file mode 100644 (file)
index 0000000..b515856
--- /dev/null
@@ -0,0 +1,47 @@
+options = {
+       filters = ["dkim"]
+       pidfile = "${TMPDIR}/rspamd.pid"
+}
+logging = {
+       type = "file",
+       level = "debug"
+       filename = "${TMPDIR}/rspamd.log"
+}
+metric = {
+       name = "default",
+       actions = {
+               reject = 100500,
+       }
+       unknown_weight = 1
+}
+
+worker {
+       type = normal
+       bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL}
+       count = 1
+       keypair {
+               pubkey = "${KEY_PUB1}";
+               privkey = "${KEY_PVT1}";
+       }
+}
+
+dkim {
+
+sign_condition =<<EOD
+return function(task)
+  local dodkim = task:get_request_header('dodkim')
+  if not dodkim then return end
+  return {
+    key = "${TESTDIR}/configs/dkim.key",
+    domain = "rspamd.tk",
+    selector = "testdkim"
+  }
+end
+EOD;
+
+  dkim_cache_size = 2k;
+  dkim_cache_expire = 1d;
+  time_jitter = 6h;
+  trusted_only = false;
+  skip_multi = false;
+}
diff --git a/test/functional/configs/dkim.key b/test/functional/configs/dkim.key
new file mode 100644 (file)
index 0000000..3bc1fb8
--- /dev/null
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANe3EETkiI1Exyrb
++VzbMSt90K8MXJA0GcyNs6MFCs9JPaTh90Zu2l7ki7m5LTUx6350AR/3hcvwjSHC
+ZjD6fvQ8/zfjN8kaLZ6DAaqtqSlpawIM+8glkuTEkIkpBED/OtDrba4Rd29iLFVu
+wQZXDtTjAAZKZPmtTZ5TXLrcCU6VAgMBAAECgYEA1BFvmBsIN8Gu/+6kNupya2xU
+NVM0yLu/xT5lpNV3LBO325oejAq8+d87kkl/LTW3a2jGFlQ0ICuLw+2mo24QUWRy
+v8if3oeBMlnLqHE+6wNjFVqo5sOjKzjO363xSXwXNUrBT7jDhnZcDN8w3/FecYKj
+ifGTVtUs1SLsYwhlc8ECQQDuCRymLZQ/imPn5eFVIydwUzg8ptZlvoA7bfIxUL9B
+QRX33s59kLCilA0tTed8Dd+GnxsT93XOj1ApIfBwmTSlAkEA5/63PDsN7fH+WInq
+VD8nU07M9S8LcGDlPbVVBr2S2I78/iwrSDAYtbkU2vEbhFK/JuKNML2j8OkzV3v1
+QulfMQJBALDzhx+l/HHr3+8RPhx7QKNIyiKUaAdEwbDsP8IXY8YPq1QThu9jM1v4
+sX7/TdkzuvoppwiFykbe1NlvCH279p0CQCmTg4Ee0DtBcCSr6rvYaZLLf329RZ6J
+LuwlMCy6ErQOxBZFEiiovfTrS2qFZToMnkc4uLbwdY36LQJTq7unGTECQCCok8Lz
+BeZtAw+TJofpOM3F2Rlm2qXiBVBeubhRedsiljG0hpvvLJBMppnQ6r27p5Jk39Sm
+aTRkxEKrxPWWLNM=
+-----END PRIVATE KEY-----
\ No newline at end of file