]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Add test for virtual symbols
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Jun 2019 18:58:46 +0000 (19:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Jun 2019 18:58:46 +0000 (19:58 +0100)
test/functional/cases/108_settings.robot
test/functional/configs/settings.conf
test/functional/lua/settings.lua

index 7b2773863cb204200c8e8ca587e20355481c255b..f1b92c214ae5c16bed4925818b8736b743c2314a 100644 (file)
@@ -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
index 27e28748090973697e489c91a2399af35b6af7c5..11f7139e5923d98794486a626e79815ae8b6ae60 100644 (file)
@@ -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";
index e52325dacf2be6d6ff6ef9ad0f338d43e32b9eb5..828e1cb37b3ef0d875a07f6aeda32036369ba2ab 100644 (file)
@@ -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,
+})