commit 86bab0c: [Test] Add tests for IDs propagation

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Aug 20 16:42:09 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-20 17:38:47 +0100
URL: https://github.com/rspamd/rspamd/commit/86bab0cc08c90f2c1a17c3c9addedc889a0500aa (HEAD -> master)

[Test] Add tests for IDs propagation

---
 test/functional/cases/108_settings.robot | 21 +++++++++++++++++++++
 test/functional/configs/settings.conf    |  9 +++++++++
 test/functional/lua/settings.lua         | 18 ++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot
index 31d04fa1e..b7c75af03 100644
--- a/test/functional/cases/108_settings.robot
+++ b/test/functional/cases/108_settings.robot
@@ -110,6 +110,7 @@ SETTINGS ID - VIRTUAL
   Check Rspamc  ${result}  SIMPLE_VIRTUAL
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -119,6 +120,7 @@ SETTINGS ID - VIRTUAL GROUP
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -128,6 +130,7 @@ SETTINGS ID - VIRTUAL FROM
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -137,6 +140,7 @@ SETTINGS ID - VIRTUAL USER
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -146,6 +150,7 @@ SETTINGS ID - VIRTUAL HOSTNAME
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -155,6 +160,7 @@ SETTINGS ID - VIRTUAL SELECTOR
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -164,6 +170,7 @@ SETTINGS ID - ANGLED RECIPIENT
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -173,6 +180,7 @@ SETTINGS ID - VIRTUAL HEADER MATCH
   Should Contain  ${result.stdout}  EXPLICIT_VIRTUAL (10
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL1
+  Should Not Contain  ${result.stdout}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -181,6 +189,7 @@ SETTINGS ID - VIRTUAL HEADER EXISTS
   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}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -189,6 +198,7 @@ SETTINGS ID - VIRTUAL HEADER ABSENT
   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}  DEP_REAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
@@ -197,6 +207,17 @@ SETTINGS ID - VIRTUAL REQUEST HEADER
   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}  DEP_REAL
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL DEP
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_virtual1
+  Check Rspamc  ${result}  EXPLICIT_VIRTUAL1
+  Should Contain  ${result.stdout}  DEP_VIRTUAL
+  Should Contain  ${result.stdout}  DEP_REAL
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_VIRTUAL
   Should Not Contain  ${result.stdout}  SIMPLE_POST
   Should Not Contain  ${result.stdout}  SIMPLE_PRE
 
diff --git a/test/functional/configs/settings.conf b/test/functional/configs/settings.conf
index 34b7613b8..0ba4de1c6 100644
--- a/test/functional/configs/settings.conf
+++ b/test/functional/configs/settings.conf
@@ -20,6 +20,15 @@ settings {
     }
   }
 
+  id_virtual1 {
+    apply {
+      symbols {
+        EXPLICIT_VIRTUAL1 = 10.0
+      }
+       symbols_enabled = ["DEP_REAL"];
+    }
+  }
+
   id_virtual_group {
     user = "test at example.com";
     from = "test2 at example.com";
diff --git a/test/functional/lua/settings.lua b/test/functional/lua/settings.lua
index d0f496c68..e072af62c 100644
--- a/test/functional/lua/settings.lua
+++ b/test/functional/lua/settings.lua
@@ -47,3 +47,21 @@ rspamd_config:register_symbol({
   group = 'vg',
   parent = id,
 })
+
+id = rspamd_config:register_symbol({
+  name = 'DEP_REAL',
+  callback = function(task)
+    task:insert_result('DEP_VIRTUAL', 1.0)
+    return true
+  end,
+  score = 1.0,
+})
+
+rspamd_config:register_symbol({
+  name = 'DEP_VIRTUAL',
+  parent = id,
+  type = 'virtual',
+  score = 1.0,
+})
+
+rspamd_config:register_dependency('DEP_VIRTUAL', 'EXPLICIT_VIRTUAL1')
\ No newline at end of file


More information about the Commits mailing list