aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2021-07-28 12:04:43 +0200
committerAndrew Lewis <nerf@judo.za.org>2021-07-28 12:27:55 +0200
commit21d90e6e98c5eb07d27503acb2b020441ea69c23 (patch)
treefab0e5203a01142e2a532071287313f2748dca3a /test
parent1f73de6e1075c0dd90d7639f01e018cc3c1f5922 (diff)
downloadrspamd-21d90e6e98c5eb07d27503acb2b020441ea69c23.tar.gz
rspamd-21d90e6e98c5eb07d27503acb2b020441ea69c23.zip
[Test] Selector that returns list of rspamd_text
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/001_merged/270_selector.robot4
-rw-r--r--test/functional/lua/selector_test.lua17
2 files changed, 21 insertions, 0 deletions
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@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,
+}