commit f13fc5a: [Test] Add moar tests for settings

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jun 25 17:42:05 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-06-25 18:37:21 +0100
URL: https://github.com/rspamd/rspamd/commit/f13fc5a747acc490f8ed99f1b15677b29cbf93f6 (HEAD -> master)

[Test] Add moar tests for settings

---
 test/functional/cases/108_settings.robot      | 67 +++++++++++++++++++++++++++
 test/functional/configs/settings.conf         | 14 ++++++
 test/functional/messages/empty-plain-text.eml |  1 +
 3 files changed, 82 insertions(+)

diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot
index 2fc27ea70..9de9a48a6 100644
--- a/test/functional/cases/108_settings.robot
+++ b/test/functional/cases/108_settings.robot
@@ -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 at 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 at 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 at 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
diff --git a/test/functional/configs/settings.conf b/test/functional/configs/settings.conf
index d46c46b30..8a68465f4 100644
--- a/test/functional/configs/settings.conf
+++ b/test/functional/configs/settings.conf
@@ -21,6 +21,20 @@ settings {
   }
 
   id_virtual_group {
+    user = "test at example.com";
+    from = "test2 at example.com";
+    hostname = "example.com";
+    selector = "rcpts:addr.in(test3 at 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;
diff --git a/test/functional/messages/empty-plain-text.eml b/test/functional/messages/empty-plain-text.eml
index 2c4fa3e90..1deeaf1ad 100644
--- a/test/functional/messages/empty-plain-text.eml
+++ b/test/functional/messages/empty-plain-text.eml
@@ -10,5 +10,6 @@ Message-ID: <d9946a191e0c97733a86424c48e65eca at test.com>
 Subject: Test Subject
 To: Me <me at me.me>
 Content-Type: text/plain; charset="UTF-8"
+Custom-Header: foo
 
 


More information about the Commits mailing list