Browse Source

[Test] Add tests for grow_factor

pull/4918/head
Andrew Lewis 2 weeks ago
parent
commit
4f3008f968

+ 37
- 0
test/functional/cases/450_grow_factor.robot View File

@@ -0,0 +1,37 @@
*** Settings ***
Suite Setup Rspamd Setup
Suite Teardown Rspamd Teardown
Library ${RSPAMD_TESTDIR}/lib/rspamd.py
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
Variables ${RSPAMD_TESTDIR}/lib/vars.py

*** Variables ***
${CONFIG} ${RSPAMD_TESTDIR}/configs/grow_factor.conf
${HAM_MESSAGE} ${RSPAMD_TESTDIR}/messages/ham.eml
${RSPAMD_SCOPE} Suite
&{RESCORED_SYMBOLS}
... SIMPLE_TEST_001=0.013067
... SIMPLE_TEST_002=14.374194
... SIMPLE_TEST_003=6.533724
... SIMPLE_TEST_004=13.067449
... SIMPLE_TEST_005=0.013067
... SIMPLE_TEST_006=0.130674
... SIMPLE_TEST_007=0.143741
... SIMPLE_TEST_008=0.156809
... SIMPLE_TEST_009=0.169876
... SIMPLE_TEST_010=0.182944
... SIMPLE_TEST_011=-0.010000
... SIMPLE_TEST_012=-0.100000
... SIMPLE_TEST_013=-10.000000

*** Test Cases ***
CHECK BASIC
Scan File ${HAM_MESSAGE}
... Settings={groups_enabled = [simple_tests]}
Expect Required Score 15
Expect Symbols With Scores &{RESCORED_SYMBOLS}

CHECK NOREJECT
Scan File ${HAM_MESSAGE}
... Settings={actions { reject = null, "add header" = 15 }, groups_enabled = [simple_tests]}
Expect Symbols With Scores &{RESCORED_SYMBOLS}

+ 8
- 0
test/functional/configs/grow_factor-local.conf View File

@@ -0,0 +1,8 @@
metric {
actions {
grow_factor = 1.1;
reject = 15;
"add header" = 6;
greylist = 4;
}
}

+ 7
- 0
test/functional/configs/grow_factor.conf View File

@@ -0,0 +1,7 @@
.include "{= env.TESTDIR =}/../../conf/rspamd.conf"

lua = "{= env.TESTDIR =}/lua/simple_plus.lua"

.include(priority=1,duplicate=merge) "{= env.TESTDIR =}/configs/grow_factor-local.conf"
.include(priority=1,duplicate=merge) "{= env.TESTDIR =}/configs/merged-local.conf"
.include(priority=2,duplicate=replace) "{= env.TESTDIR =}/configs/merged-override.conf"

+ 28
- 0
test/functional/lua/simple_plus.lua View File

@@ -0,0 +1,28 @@
local test_symbols = {
SIMPLE_TEST_001 = 0.01,
SIMPLE_TEST_002 = 11,
SIMPLE_TEST_003 = 5.0,
SIMPLE_TEST_004 = 10.0,
SIMPLE_TEST_005 = 0.01,
SIMPLE_TEST_006 = 0.10,
SIMPLE_TEST_007 = 0.11,
SIMPLE_TEST_008 = 0.12,
SIMPLE_TEST_009 = 0.13,
SIMPLE_TEST_010 = 0.14,
SIMPLE_TEST_011 = -0.01,
SIMPLE_TEST_012 = -0.1,
SIMPLE_TEST_013 = -10.0,
}

for k, v in pairs(test_symbols) do

rspamd_config:register_symbol({
name = k,
group = 'simple_tests',
score = v,
callback = function()
return true
end
})

end

Loading…
Cancel
Save