From 225c8d92b64b76bc122d462966dc35109a399da2 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Tue, 1 Feb 2022 13:09:19 +0200 Subject: [Test] task:remove_symbol() on grouped virtual symbol --- test/functional/cases/001_merged/101_lua.robot | 5 +++++ test/functional/configs/merged.conf | 1 + test/functional/lua/remove_result.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 test/functional/lua/remove_result.lua diff --git a/test/functional/cases/001_merged/101_lua.robot b/test/functional/cases/001_merged/101_lua.robot index 23637396a..ac4f8677a 100644 --- a/test/functional/cases/001_merged/101_lua.robot +++ b/test/functional/cases/001_merged/101_lua.robot @@ -34,6 +34,11 @@ Option Order Expect Symbol With Exact Options OPTION_ORDER one two three 4 5 a Expect Symbol With Exact Options TBL_OPTION_ORDER one two three 4 5 a +Remove Result + Scan File ${MESSAGE} Settings={symbols_enabled = [REMOVE_RESULT_EXPECTED, REMOVE_RESULT_UNEXPECTED]} + Expect Symbol REMOVE_RESULT_EXPECTED + Do Not Expect Symbol REMOVE_RESULT_UNEXPECTED + Rule conditions Scan File ${MESSAGE} Settings={symbols_enabled = [ANY_A]} Expect Symbol With Option ANY_A hello3 diff --git a/test/functional/configs/merged.conf b/test/functional/configs/merged.conf index bda7044e1..60930f657 100644 --- a/test/functional/configs/merged.conf +++ b/test/functional/configs/merged.conf @@ -8,6 +8,7 @@ lua = "{= env.TESTDIR =}/lua/hashes.lua" lua = "{= env.TESTDIR =}/lua/maps_kv.lua" lua = "{= env.TESTDIR =}/lua/option_order.lua" lua = "{= env.TESTDIR =}/lua/recipients.lua" +lua = "{= env.TESTDIR =}/lua/remove_result.lua" lua = "{= env.TESTDIR =}/lua/tlds.lua" # 104_get_from diff --git a/test/functional/lua/remove_result.lua b/test/functional/lua/remove_result.lua new file mode 100644 index 000000000..106d7f4cc --- /dev/null +++ b/test/functional/lua/remove_result.lua @@ -0,0 +1,26 @@ +local id = rspamd_config:register_symbol({ + name = 'REMOVE_RESULT_CB', + callback = function(task) + task:insert_result('REMOVE_RESULT_UNEXPECTED', 1.0, 'ohno') + end, + type = 'callback', +}) + +rspamd_config:register_symbol({ + name = 'REMOVE_RESULT_UNEXPECTED', + type = 'virtual', + score = 0.1, + group = 'remove_result_test', + parent = id, +}) + +rspamd_config:register_symbol({ + name = 'REMOVE_RESULT_EXPECTED', + callback = function(task) + return task:remove_result('REMOVE_RESULT_UNEXPECTED') and true or false + end, + type = 'normal', + score = 0.1, +}) + +rspamd_config:register_dependency('REMOVE_RESULT_EXPECTED', 'REMOVE_RESULT_UNEXPECTED') -- cgit v1.2.3