summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-15 15:49:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-15 15:49:58 +0100
commit5dfabf334545326059c7b652cae9e0789c965e9f (patch)
tree0a92133be579b083be3744d120667d38e5341b13 /test
parent9c8d32c7a237d889153d0bc3a444d568195eaabf (diff)
downloadrspamd-5dfabf334545326059c7b652cae9e0789c965e9f.tar.gz
rspamd-5dfabf334545326059c7b652cae9e0789c965e9f.zip
[Test] Add options in composites tests
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/109_composites.robot20
-rw-r--r--test/functional/configs/composites.conf10
-rw-r--r--test/functional/lua/composites.lua14
3 files changed, 44 insertions, 0 deletions
diff --git a/test/functional/cases/109_composites.robot b/test/functional/cases/109_composites.robot
index d24c505e9..1216e4c88 100644
--- a/test/functional/cases/109_composites.robot
+++ b/test/functional/cases/109_composites.robot
@@ -63,3 +63,23 @@ Composites - Symbol groups
Should Contain ${result.stdout} ANY_A (-1.00)
Should Contain ${result.stdout} NEGATIVE_B (1.00)
Should Not Contain ${result.stdout} NEGATIVE_A
+
+Composites - Opts Plain
+ ${result} = Scan Message With Rspamc ${MESSAGE} --header=opts:sym1
+ Check Rspamc ${result} SYMOPTS1 (5.00)
+ Should Not Contain ${result.stdout} SYMOPTS2
+
+Composites - Opts RE Miss one
+ ${result} = Scan Message With Rspamc ${MESSAGE} --header=opts:sym1,foo1
+ Check Rspamc ${result} SYMOPTS1 (5.00)
+ Should Not Contain ${result.stdout} SYMOPTS2
+
+Composites - Opts RE Miss both
+ ${result} = Scan Message With Rspamc ${MESSAGE} --header=opts:sym2
+ Should Not Contain ${result.stdout} SYMOPTS1
+ Should Not Contain ${result.stdout} SYMOPTS2
+
+Composites - Opts RE Hit
+ ${result} = Scan Message With Rspamc ${MESSAGE} --header=opts:sym2,foo1
+ Check Rspamc ${result} SYMOPTS2 (6.00)
+ Should Not Contain ${result.stdout} SYMOPTS1 \ No newline at end of file
diff --git a/test/functional/configs/composites.conf b/test/functional/configs/composites.conf
index 8b79d5ae7..932b25fc1 100644
--- a/test/functional/configs/composites.conf
+++ b/test/functional/configs/composites.conf
@@ -66,4 +66,14 @@ composites {
expression = "!g+:positive & g-:negative & -g:any";
score = 5.0;
}
+
+ SYMOPTS1 {
+ expression = "OPTS[sym1]";
+ score = 5.0;
+ }
+
+ SYMOPTS2 {
+ expression = "OPTS[/foo.*/,sym2]";
+ score = 6.0;
+ }
}
diff --git a/test/functional/lua/composites.lua b/test/functional/lua/composites.lua
index 66d595cd8..648eda0ff 100644
--- a/test/functional/lua/composites.lua
+++ b/test/functional/lua/composites.lua
@@ -124,3 +124,17 @@ rspamd_config:register_symbol({
return true, 'Fires always'
end
})
+
+rspamd_config:register_symbol({
+ name = 'OPTS',
+ score = -1.0,
+ group = "any",
+ callback = function(task)
+ local lua_util = require "lua_util"
+ local woot = lua_util.str_split(tostring(task:get_request_header('opts') or ''), ',')
+
+ if woot and #woot > 0 and #woot[1] > 0 then
+ return true, 1.0, woot
+ end
+ end
+})