]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Selector that returns list of rspamd_text 3829/head
authorAndrew Lewis <nerf@judo.za.org>
Wed, 28 Jul 2021 10:04:43 +0000 (12:04 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 28 Jul 2021 10:27:55 +0000 (12:27 +0200)
test/functional/cases/001_merged/270_selector.robot
test/functional/lua/selector_test.lua

index 8250db89ec5e51dce8441a6e1dd4856c6ea5a7ca..fa3ab8753a7b2d560d62fbc8105d5e2341116f75 100644 (file)
@@ -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
index f1bb45269b205331cb909030dff809a1cff57549..dd52ee3ed14a667cb19217629f291e0da804db7f 100644 (file)
@@ -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,
+}