commit ab3698b: [Test] Add test for virtual symbols

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jun 14 19:00:27 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-06-14 19:58:46 +0100
URL: https://github.com/rspamd/rspamd/commit/ab3698b6fa4613ea34bc3ad52c8cfcea9418c870 (HEAD -> master)

[Test] Add test for virtual symbols

---
 test/functional/cases/108_settings.robot | 14 ++++++++++++++
 test/functional/configs/settings.conf    | 12 ++++++++++++
 test/functional/lua/settings.lua         | 13 +++++++++++--
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot
index 7b2773863..f1b92c214 100644
--- a/test/functional/cases/108_settings.robot
+++ b/test/functional/cases/108_settings.robot
@@ -95,6 +95,20 @@ SETTINGS ID - PRE
   Should Not Contain  ${result.stdout}  SIMPLE_TEST
   Should Not Contain  ${result.stdout}  SIMPLE_POST
 
+SETTINGS ID - VIRTUAL
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_virtual
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  Should Not Contain  ${result.stdout}  SIMPLE_POST
+  Should Not Contain  ${result.stdout}  SIMPLE_PRE
+
+SETTINGS ID - VIRTUAL GROUP
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_virtual_group
+  Check Rspamc  ${result}  SIMPLE_VIRTUAL
+  Should Not Contain  ${result.stdout}  SIMPLE_TEST
+  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 27e287480..11f7139e5 100644
--- a/test/functional/configs/settings.conf
+++ b/test/functional/configs/settings.conf
@@ -13,6 +13,18 @@ settings {
       symbols_enabled = ["SIMPLE_PRE"];
     }
   }
+
+  id_virtual {
+    apply {
+      symbols_enabled = ["SIMPLE_VIRTUAL"];
+    }
+  }
+
+  id_virtual_group {
+    apply {
+      groups_enabled = ["vg"];
+    }
+  }
 }
 classifier {
   backend = "sqlite3";
diff --git a/test/functional/lua/settings.lua b/test/functional/lua/settings.lua
index e52325dac..828e1cb37 100644
--- a/test/functional/lua/settings.lua
+++ b/test/functional/lua/settings.lua
@@ -19,11 +19,20 @@ rspamd_config:register_symbol({
   end
 })
 
-rspamd_config:register_symbol({
+local id = rspamd_config:register_symbol({
   name = 'SIMPLE_TEST',
   score = 1.0,
   group = 'b',
-  callback = function()
+  callback = function(task)
+    task:insert_result('SIMPLE_VIRTUAL', 1.0)
     return true, 'Fires always'
   end
 })
+
+rspamd_config:register_symbol({
+  name = 'SIMPLE_VIRTUAL',
+  type = 'virtual',
+  score = 1.0,
+  group = 'vg',
+  parent = id,
+})


More information about the Commits mailing list