commit 21d90e6: [Test] Selector that returns list of rspamd_text

Andrew Lewis nerf at judo.za.org
Wed Jul 28 11:00:04 UTC 2021


Author: Andrew Lewis
Date: 2021-07-28 12:04:43 +0200
URL: https://github.com/rspamd/rspamd/commit/21d90e6e98c5eb07d27503acb2b020441ea69c23 (refs/pull/3829/head)

[Test] Selector that returns list of rspamd_text

---
 test/functional/cases/001_merged/270_selector.robot |  4 ++++
 test/functional/lua/selector_test.lua               | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/test/functional/cases/001_merged/270_selector.robot b/test/functional/cases/001_merged/270_selector.robot
index 8250db89e..fa3ab8753 100644
--- a/test/functional/cases/001_merged/270_selector.robot
+++ b/test/functional/cases/001_merged/270_selector.robot
@@ -13,3 +13,7 @@ Newlines
   Expect Symbol  CONFIG_SELECTOR_RE_RCPT_SUBJECT
   Expect Symbol  LUA_SELECTOR_RE
 
+Rspamd_text selector
+  Scan File  ${MESSAGE}
+  ...  Settings={symbols_enabled = [RSPAMD_TEXT_SELECTOR]}
+  Expect Symbol  RSPAMD_TEXT_SELECTOR
diff --git a/test/functional/lua/selector_test.lua b/test/functional/lua/selector_test.lua
index f1bb45269..dd52ee3ed 100644
--- a/test/functional/lua/selector_test.lua
+++ b/test/functional/lua/selector_test.lua
@@ -1,6 +1,23 @@
+local lua_selectors = require 'lua_selectors'
+local rspamd_text = require 'rspamd_text'
+
 rspamd_config:register_re_selector('test', 'user.lower;header(Subject).lower', ' ')
 
 config['regexp']['LUA_SELECTOR_RE'] = {
   re = 'test=/^test at user\\.com some subject$/{selector}',
   score = 100500,
 }
+
+lua_selectors.register_extractor(rspamd_config, 'some_rspamd_text', {
+  get_value = function()
+    return {rspamd_text.fromstring('hello'), rspamd_text.fromstring('world')}, 'string_list'
+  end,
+  description = 'Return some rspamd_texts',
+})
+
+rspamd_config:register_re_selector('some_rspamd_text_re', 'some_rspamd_text', ' ')
+
+config['regexp']['RSPAMD_TEXT_SELECTOR'] = {
+  re = 'some_rspamd_text_re=/^hello$/{selector}',
+  score = 1,
+}


More information about the Commits mailing list