]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Add moar tests for settings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Jun 2019 17:37:21 +0000 (18:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Jun 2019 17:37:21 +0000 (18:37 +0100)
test/functional/cases/108_settings.robot
test/functional/configs/settings.conf
test/functional/messages/empty-plain-text.eml

index 2fc27ea701cf545c909d314dc84c2767ce15f231..9de9a48a6313cb7e5eb12f91348f40a447569b6f 100644 (file)
@@ -9,6 +9,9 @@ Variables       ${TESTDIR}/lib/vars.py
 ${CONFIG}       ${TESTDIR}/configs/plugins.conf
 ${LUA_SCRIPT}   ${TESTDIR}/lua/settings.lua
 ${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
+${MESSAGE_7BIT}      ${TESTDIR}/messages/utf.eml
+${MESSAGE_CUSTOM_HDR}      ${TESTDIR}/messages/empty-plain-text.eml
+${MESSAGE_ABSENT_MIME}      ${TESTDIR}/messages/ed25519.eml
 ${SPAM_MESSAGE}      ${TESTDIR}/messages/spam.eml
 ${HAM_MESSAGE}      ${TESTDIR}/messages/ham.eml
 ${RSPAMD_SCOPE}  Suite
@@ -113,6 +116,70 @@ SETTINGS ID - VIRTUAL GROUP
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
+SETTINGS ID - VIRTUAL FROM
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --from  test2@example.com
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL USER
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --user  test@example.com
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL HOSTNAME
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --hostname  example.com
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL SELECTOR
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --rcpt  user3@example.com
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL HEADER MATCH
+  ${result} =  Scan Message With Rspamc  ${MESSAGE_7BIT}
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL HEADER EXISTS
+  ${result} =  Scan Message With Rspamc  ${MESSAGE_CUSTOM_HDR}
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL HEADER ABSENT
+  ${result} =  Scan Message With Rspamc  ${MESSAGE_ABSENT_MIME}
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL REQUEST HEADER
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Test=passed
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL (10
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
 *** Keywords ***
 Settings Setup
   Copy File  ${TESTDIR}/data/bayes.spam.sqlite3  /tmp/bayes.spam.sqlite3
index d46c46b3069c0489226e6bdc73926a85e3720de7..8a68465f4a7e6a97f7fa837e79fd160a7792800e 100644 (file)
@@ -21,6 +21,20 @@ settings {
   }
 
   id_virtual_group {
+    user = "test@example.com";
+    from = "test2@example.com";
+    hostname = "example.com";
+    selector = "rcpts:addr.in(test3@example.com)";
+    header = {
+      "Content-Transfer-Encoding" = "7bit";
+      "Custom-Header" = true;
+      "Mime-Version" = false;
+    }
+    request_header = {
+      "Test" = "passed";
+    }
+
+    expression = 'user || from || hostname || selector:1 || header:mime_version || header:custom_header || header:1 || request_header:test'
     apply {
       groups_enabled = ["vg"];
       SIMPLE_VIRTUAL = 10.0;
index 2c4fa3e90bd0529f5dd9e10f8d847d9e041d1c4f..1deeaf1ad4803cf45a575375797459811f054d16 100644 (file)
@@ -10,5 +10,6 @@ Message-ID: <d9946a191e0c97733a86424c48e65eca@test.com>
 Subject: Test Subject
 To: Me <me@me.me>
 Content-Type: text/plain; charset="UTF-8"
+Custom-Header: foo