From 86bab0cc08c90f2c1a17c3c9addedc889a0500aa Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 20 Aug 2019 17:38:47 +0100 Subject: [PATCH] [Test] Add tests for IDs propagation --- test/functional/cases/108_settings.robot | 21 +++++++++++++++++++++ test/functional/configs/settings.conf | 9 +++++++++ test/functional/lua/settings.lua | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot index 31d04fa1e..b7c75af03 100644 --- a/test/functional/cases/108_settings.robot +++ b/test/functional/cases/108_settings.robot @@ -110,6 +110,7 @@ SETTINGS ID - VIRTUAL Check Rspamc ${result} SIMPLE_VIRTUAL Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -119,6 +120,7 @@ SETTINGS ID - VIRTUAL GROUP Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -128,6 +130,7 @@ SETTINGS ID - VIRTUAL FROM Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -137,6 +140,7 @@ SETTINGS ID - VIRTUAL USER Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -146,6 +150,7 @@ SETTINGS ID - VIRTUAL HOSTNAME Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -155,6 +160,7 @@ SETTINGS ID - VIRTUAL SELECTOR Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -164,6 +170,7 @@ SETTINGS ID - ANGLED RECIPIENT Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -173,6 +180,7 @@ SETTINGS ID - VIRTUAL HEADER MATCH Should Contain ${result.stdout} EXPLICIT_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -181,6 +189,7 @@ SETTINGS ID - VIRTUAL HEADER EXISTS Check Rspamc ${result} SIMPLE_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -189,6 +198,7 @@ SETTINGS ID - VIRTUAL HEADER ABSENT Check Rspamc ${result} SIMPLE_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE @@ -197,6 +207,17 @@ SETTINGS ID - VIRTUAL REQUEST HEADER Check Rspamc ${result} SIMPLE_VIRTUAL (10 Should Not Contain ${result.stdout} SIMPLE_TEST Should Not Contain ${result.stdout} SIMPLE_VIRTUAL1 + Should Not Contain ${result.stdout} DEP_REAL + Should Not Contain ${result.stdout} SIMPLE_POST + Should Not Contain ${result.stdout} SIMPLE_PRE + +SETTINGS ID - VIRTUAL DEP + ${result} = Scan Message With Rspamc ${MESSAGE} --header Settings-Id=id_virtual1 + Check Rspamc ${result} EXPLICIT_VIRTUAL1 + Should Contain ${result.stdout} DEP_VIRTUAL + Should Contain ${result.stdout} DEP_REAL + Should Not Contain ${result.stdout} SIMPLE_TEST + Should Not Contain ${result.stdout} SIMPLE_VIRTUAL Should Not Contain ${result.stdout} SIMPLE_POST Should Not Contain ${result.stdout} SIMPLE_PRE diff --git a/test/functional/configs/settings.conf b/test/functional/configs/settings.conf index 34b7613b8..0ba4de1c6 100644 --- a/test/functional/configs/settings.conf +++ b/test/functional/configs/settings.conf @@ -20,6 +20,15 @@ settings { } } + id_virtual1 { + apply { + symbols { + EXPLICIT_VIRTUAL1 = 10.0 + } + symbols_enabled = ["DEP_REAL"]; + } + } + id_virtual_group { user = "test@example.com"; from = "test2@example.com"; diff --git a/test/functional/lua/settings.lua b/test/functional/lua/settings.lua index d0f496c68..e072af62c 100644 --- a/test/functional/lua/settings.lua +++ b/test/functional/lua/settings.lua @@ -47,3 +47,21 @@ rspamd_config:register_symbol({ group = 'vg', parent = id, }) + +id = rspamd_config:register_symbol({ + name = 'DEP_REAL', + callback = function(task) + task:insert_result('DEP_VIRTUAL', 1.0) + return true + end, + score = 1.0, +}) + +rspamd_config:register_symbol({ + name = 'DEP_VIRTUAL', + parent = id, + type = 'virtual', + score = 1.0, +}) + +rspamd_config:register_dependency('DEP_VIRTUAL', 'EXPLICIT_VIRTUAL1') \ No newline at end of file -- 2.39.5