diff options
Diffstat (limited to 'test/functional/cases')
23 files changed, 186 insertions, 412 deletions
diff --git a/test/functional/cases/__init__.robot b/test/functional/cases/__init__.robot new file mode 100644 index 000000000..46fdc8f2a --- /dev/null +++ b/test/functional/cases/__init__.robot @@ -0,0 +1,18 @@ +*** Settings *** +Suite Setup Export Global Variables +Library ../lib/rspamd.py +Variables ../lib/vars.py + +*** Keywords *** +Export Global Variables + ${TESTDIR} = Get Test Directory + Set Global Variable ${KEY_PUB1} + Set Global Variable ${KEY_PVT1} + Set Global Variable ${LOCAL_ADDR} + Set Global Variable ${PORT_CONTROLLER} + Set Global Variable ${PORT_NORMAL} + Set Global Variable ${RSPAMC} ${TESTDIR}/../../src/client/rspamc + Set Global Variable ${RSPAMD} ${TESTDIR}/../../src/rspamd + Set Global Variable ${RSPAMD_GROUP} + Set Global Variable ${RSPAMD_USER} + Set Global Variable ${TESTDIR} diff --git a/test/functional/cases/deps.lua b/test/functional/cases/deps.lua deleted file mode 100644 index 581825400..000000000 --- a/test/functional/cases/deps.lua +++ /dev/null @@ -1,32 +0,0 @@ -local logger = require "rspamd_logger" - -local cb = function(task) - task:insert_result('TOP', 1.0) -end - -local cb_dep1 = function(task) - if task:get_symbol('TOP') then - task:insert_result('DEP1', 1.0) - end -end - -local cb_gen = function(num) - local cb_dep = function(task) - if task:get_symbol('DEP' .. tostring(num)) then - task:insert_result('DEP' .. tostring(num + 1), 1.0) - end - end - - return cb_dep -end - -local id = rspamd_config:register_callback_symbol(1.0, cb) -rspamd_config:register_virtual_symbol('TOP', 1.0, id) - -rspamd_config:register_symbol('DEP1', 1.0, cb_dep1) -rspamd_config:register_dependency('DEP1', 'TOP') - -for i = 2,10 do - rspamd_config:register_symbol('DEP' .. tostring(i), 1.0, cb_gen(i - 1)) - rspamd_config:register_dependency('DEP' .. tostring(i), 'DEP' .. tostring(i - 1)) -end
\ No newline at end of file diff --git a/test/functional/cases/encrypted_gtube.sh b/test/functional/cases/encrypted_gtube.sh deleted file mode 100644 index 016a1f6ec..000000000 --- a/test/functional/cases/encrypted_gtube.sh +++ /dev/null @@ -1,9 +0,0 @@ -# Test rspamd encrypted using gtube - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/trivial.conf" -run_rspamd -run_rspamc symbols --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/gtube.eml" -check_output 'Action: reject'
\ No newline at end of file diff --git a/test/functional/cases/flags.lua b/test/functional/cases/flags.lua deleted file mode 100644 index 61f135f1c..000000000 --- a/test/functional/cases/flags.lua +++ /dev/null @@ -1,37 +0,0 @@ ---[[ -Copyright (c) 2015, Vsevolod Stakhov <vsevolod@highsecure.ru> -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -]]-- - -local logger = require "rspamd_logger" - -rspamd_config:register_post_filter(function(task) - task:set_flag('no_stat') - task:set_flag('no_log', false) - task:set_flag('no_log', true) - task:set_flag('skip', true) - task:set_flag('extended_urls') - - task:insert_result('FLAGS_SYM', 1.0, table.concat(task:get_flags(), ',')) -end) diff --git a/test/functional/cases/general.robot b/test/functional/cases/general.robot new file mode 100644 index 000000000..4016b9a6a --- /dev/null +++ b/test/functional/cases/general.robot @@ -0,0 +1,38 @@ +*** Settings *** +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Suite Setup Generic Setup +Suite Teardown Generic Teardown + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/trivial.conf +${GTUBE} ${TESTDIR}/messages/gtube.eml +&{RSPAMD_KEYWORDS} KEY_PUBLIC=${KEY_PUB1} KEY_PRIVATE=${KEY_PVT1} LOCAL_ADDR=${LOCAL_ADDR} PORT_NORMAL=${PORT_NORMAL} TESTDIR=${TESTDIR} +${RSPAMD_SCOPE} Suite + +*** Test Cases *** +GTUBE + ${result} = Scan Message With Rspamc ${GTUBE} + Follow Rspamd Log + Should Contain ${result.stdout} GTUBE ( + +GTUBE - Encrypted + ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} --key ${KEY_PUB1} ${GTUBE} + Follow Rspamd Log + Should Contain ${result.stdout} GTUBE ( + +GTUBE - Scan File feature + ${result} = Scan File ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} + Follow Rspamd Log + Should Contain ${result} GTUBE + +GTUBE - Scan File feature (encoded) + ${encoded} = Encode Filename ${GTUBE} + ${result} = Scan File ${LOCAL_ADDR} ${PORT_NORMAL} ${encoded} + Follow Rspamd Log + Should Contain ${result} GTUBE + +GTUBE - SPAMC + ${result} = Spamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} + Follow Rspamd Log + Should Contain ${result} GTUBE diff --git a/test/functional/cases/gtube.sh b/test/functional/cases/gtube.sh deleted file mode 100644 index 795b0dc45..000000000 --- a/test/functional/cases/gtube.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Test rspamd using gtube - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/trivial.conf" -run_rspamd -run_rspamc symbols "$TEST_DIRNAME/messages/gtube.eml" -check_output "$output" 'Action: reject'
\ No newline at end of file diff --git a/test/functional/cases/http_streamline.pl b/test/functional/cases/http_streamline.pl deleted file mode 100644 index e5afc5aff..000000000 --- a/test/functional/cases/http_streamline.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env perl - -use warnings; -use strict; - -use Socket; - -my $host = "127.0.0.1"; -my $port = 56789; -my $input = shift; - -open(INPUT, "< $input") or die "Can't open input file $input\n"; - -socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]) - or die "Can't create a socket $!\n"; -connect(SOCKET, pack_sockaddr_in($port, inet_aton($host))) - or die "Can't connect to port $port! \n"; - -print SOCKET "POST /symbols HTTP/1.0\r\n\r\n"; - -while (my $line = <INPUT>) { - print SOCKET $line; -} - -SOCKET->autoflush(1); - -shutdown(SOCKET, 1); - -close(INPUT); - -while (my $line = <SOCKET>) { - print $line; -} - -close(SOCKET); diff --git a/test/functional/cases/learn_bad.sh b/test/functional/cases/learn_bad.sh deleted file mode 100644 index 5c5410c91..000000000 --- a/test/functional/cases/learn_bad.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Test rspamd learn with bad stats - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=/non/existent - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'cannot open backend'
\ No newline at end of file diff --git a/test/functional/cases/learn_empty.sh b/test/functional/cases/learn_empty.sh deleted file mode 100644 index 855979fd3..000000000 --- a/test/functional/cases/learn_empty.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Test rspamd learn empty part - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=${TMPDIR} - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$BATS_TEST_DIRNAME/messages/empty_part.eml" -check_output $output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$BATS_TEST_DIRNAME/messages/empty_part.eml" -check_output $output 'BAYES_SPAM'
\ No newline at end of file diff --git a/test/functional/cases/learn_simple.sh b/test/functional/cases/learn_simple.sh deleted file mode 100644 index d44056918..000000000 --- a/test/functional/cases/learn_simple.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Test rspamd learn - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=${TMPDIR} - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_SPAM'
\ No newline at end of file diff --git a/test/functional/cases/learn_siphash.sh b/test/functional/cases/learn_siphash.sh deleted file mode 100644 index dcab7410a..000000000 --- a/test/functional/cases/learn_siphash.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Test rspamd learn using siphash - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=${TMPDIR} \ - STATS_HASH="siphash" - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_SPAM'
\ No newline at end of file diff --git a/test/functional/cases/learn_xxhash.sh b/test/functional/cases/learn_xxhash.sh deleted file mode 100644 index 2b75b9aa5..000000000 --- a/test/functional/cases/learn_xxhash.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Test rspamd learn using xxhash - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=${TMPDIR} \ - STATS_HASH="xxh" - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_SPAM'
\ No newline at end of file diff --git a/test/functional/cases/lua.robot b/test/functional/cases/lua.robot new file mode 100644 index 000000000..b8005cd8f --- /dev/null +++ b/test/functional/cases/lua.robot @@ -0,0 +1,31 @@ +*** Settings *** +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/lua_test.conf +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${RSPAMD_SCOPE} Test + +*** Keywords *** +Lua Setup + [Arguments] ${lua_script} + &{RSPAMD_KEYWORDS} = Create Dictionary LOCAL_ADDR=${LOCAL_ADDR} LUA_SCRIPT=${lua_script} PORT_CONTROLLER=${PORT_CONTROLLER} PORT_NORMAL=${PORT_NORMAL} TESTDIR=${TESTDIR} + Set Test Variable &{RSPAMD_KEYWORDS} + Generic Setup + +*** Test Cases *** +Flags + [Setup] Lua Setup ${TESTDIR}/lua/flags.lua + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} stat + Should Contain ${result.stdout} Messages scanned: 0 + [Teardown] Generic Teardown + +Dependencies + [Setup] Lua Setup ${TESTDIR}/lua/deps.lua + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} DEP10 + [Teardown] Generic Teardown diff --git a/test/functional/cases/relearn-sqlite.sh b/test/functional/cases/relearn-sqlite.sh deleted file mode 100644 index f678b319c..000000000 --- a/test/functional/cases/relearn-sqlite.sh +++ /dev/null @@ -1,28 +0,0 @@ -# Test rspamd re-learn sqlite3 backend - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=${TMPDIR} \ - STATS_BACKEND="sqlite3" - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_SPAM' - -run_rspamc learn_ham \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_HAM'
\ No newline at end of file diff --git a/test/functional/cases/relearn.sh b/test/functional/cases/relearn.sh deleted file mode 100644 index 9d52e4310..000000000 --- a/test/functional/cases/relearn.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Test rspamd re-learn - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/stats.conf" \ - STATSDIR=${TMPDIR} - -run_rspamd -run_rspamc learn_spam \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_SPAM' - -run_rspamc learn_ham \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'success.*true' - -run_rspamc symbols \ - --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'BAYES_HAM'
\ No newline at end of file diff --git a/test/functional/cases/reload.sh b/test/functional/cases/reload.sh deleted file mode 100644 index cb1ce0ba3..000000000 --- a/test/functional/cases/reload.sh +++ /dev/null @@ -1,23 +0,0 @@ -# Test rspamd reload - -. ${TEST_DIRNAME}/functions.sh - -sed -e 's|@@LUA_SCRIPT@@|${TESTDIR}/cases/deps.lua|' < \ - "$TEST_DIRNAME/configs/lua_test.conf" > \ - "$TMPDIR/rspamd.conf" -export RSPAMD_CONFIG="$TMPDIR/rspamd.conf" \ - STATSDIR=${TMPDIR} -run_rspamd - -run_rspamc symbols \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'DEP10' - -kill -HUP `cat ${TMPDIR}/rspamd.pid` -sleep 0.5 -kill -HUP `cat ${TMPDIR}/rspamd.pid` -sleep 0.5 - -run_rspamc symbols \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'DEP10'
\ No newline at end of file diff --git a/test/functional/cases/scan_file.pl b/test/functional/cases/scan_file.pl deleted file mode 100644 index 674d4aee6..000000000 --- a/test/functional/cases/scan_file.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env perl - -use warnings; -use strict; - -use Socket; - -my $host = "127.0.0.1"; -my $port = 56789; -my $input_file = shift; - -socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]) - or die "Can't create a socket $!\n"; -connect(SOCKET, pack_sockaddr_in($port, inet_aton($host))) - or die "Can't connect to port $port! \n"; - -print SOCKET "GET /symbols?${input_file} HTTP/1.0\r\n\r\n"; - -SOCKET->autoflush(1); - -shutdown(SOCKET, 1); - -while (my $line = <SOCKET>) { - print $line; -} - -close(SOCKET); - diff --git a/test/functional/cases/scan_file.sh b/test/functional/cases/scan_file.sh deleted file mode 100644 index 107d335e4..000000000 --- a/test/functional/cases/scan_file.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Test rspamd gtube using scan file feature - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/trivial.conf" -run_rspamd -run perl "$TEST_DIRNAME/cases/scan_file.pl" "file=$TEST_DIRNAME/messages/gtube.eml" -check_output 'GTUBE' - -run perl "$TEST_DIRNAME/cases/scan_file.pl" "path=$TEST_DIRNAME/messages/gtube.eml" -check_output 'GTUBE' - -run perl "$TEST_DIRNAME/cases/scan_file.pl" "path=\"$TEST_DIRNAME/messages/gtube.eml\"" -check_output 'GTUBE' - -# Hex encode every character -_hex_name=`printf "$TEST_DIRNAME/messages/gtube.eml" | hexdump -v -e '/1 "%02x"' | sed 's/\(..\)/%\1/g'` - -run perl "$TEST_DIRNAME/cases/scan_file.pl" "file=${_hex_name}" -check_output 'GTUBE' - -_hex_name=`printf "\"$TEST_DIRNAME/messages/gtube.eml\"" | hexdump -v -e '/1 "%02x"' | sed 's/\(..\)/%\1/g'` -run perl "$TEST_DIRNAME/cases/scan_file.pl" "path=${_hex_name}" -check_output 'GTUBE' diff --git a/test/functional/cases/spamc.pl b/test/functional/cases/spamc.pl deleted file mode 100644 index abeefb8b4..000000000 --- a/test/functional/cases/spamc.pl +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env perl - -use warnings; -use strict; - -use Socket; - -my $host = "127.0.0.1"; -my $port = 56789; -my $input = shift; - -open(INPUT, "< $input") or die "Can't open input file $input\n"; - -socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]) - or die "Can't create a socket $!\n"; -connect(SOCKET, pack_sockaddr_in($port, inet_aton($host))) - or die "Can't connect to port $port! \n"; - -print SOCKET "SYMBOLS SPAMC/1.0\r\n"; - -my $msg; -while (my $line = <INPUT>) { - $msg .= $line; -} - -my $dlen = length($msg); -print SOCKET "Content-length: $dlen\r\n\r\n$msg"; - -SOCKET->autoflush(1); - -shutdown(SOCKET, 1); - -close(INPUT); - -while (my $line = <SOCKET>) { - print $line; -} - -close(SOCKET); - diff --git a/test/functional/cases/spamc_gtube.sh b/test/functional/cases/spamc_gtube.sh deleted file mode 100644 index ffad990eb..000000000 --- a/test/functional/cases/spamc_gtube.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Test rspamd spamc gtube - -. ${TEST_DIRNAME}/functions.sh - -export RSPAMD_CONFIG="$TEST_DIRNAME/configs/trivial.conf" -run_rspamd -run perl "$TEST_DIRNAME/cases/spamc.pl" "$TEST_DIRNAME/messages/gtube.eml" -check_output 'GTUBE'
\ No newline at end of file diff --git a/test/functional/cases/statistics.robot b/test/functional/cases/statistics.robot new file mode 100644 index 000000000..d9df49813 --- /dev/null +++ b/test/functional/cases/statistics.robot @@ -0,0 +1,99 @@ +*** Settings *** +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot + +*** Variables *** +@{ALIASES} STATSDIR +${CONFIG} ${TESTDIR}/configs/stats.conf +${MESSAGE} ${TESTDIR}/messages/spam_message.eml +${RSPAMD_SCOPE} Test + +*** Keywords *** +Statistics Setup + [Arguments] @{aliases} &{kw} + &{RSPAMD_KEYWORDS} = Create Dictionary KEY_PRIVATE=${KEY_PVT1} KEY_PUBLIC=${KEY_PUB1} LOCAL_ADDR=${LOCAL_ADDR} PORT_CONTROLLER=${PORT_CONTROLLER} PORT_NORMAL=${PORT_NORMAL} TESTDIR=${TESTDIR} + Update Dictionary ${RSPAMD_KEYWORDS} ${kw} + Set Test Variable &{RSPAMD_KEYWORDS} + ${TMPDIR} ${RSPAMD_PID} ${RSPAMD_LOGPOS} = Run Rspamd @{aliases} &{RSPAMD_KEYWORDS} + Export Rspamd Vars To Test ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID} + +*** Test Cases *** +Sqlite Learn - Keyed, siphash + [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=siphash STATS_KEY=${KEY_PVT1} + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Should Contain ${result.stdout} success = true + Follow Rspamd Log + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_SPAM + [Teardown] Generic Teardown + +Sqlite Learn - Keyed, xxhash + [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1} + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_SPAM + [Teardown] Generic Teardown + +Sqlite Learn - Broken Stats Directory + [Setup] Statistics Setup @{EMPTY} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1} STATSDIR=/does/not/exist + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Follow Rspamd Log + Should Not Contain ${result.stdout} success = true + [Teardown] Generic Teardown + +Sqlite Learn - Empty part + [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1} + Set Test Variable ${MESSAGE} ${TESTDIR}/messages/empty_part.eml + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_SPAM + [Teardown] Generic Teardown + +Sqlite Relearn + [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=sqlite3 STATS_HASH=xxh STATS_KEY=${KEY_PVT1} + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_SPAM + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_ham ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_HAM + [Teardown] Generic Teardown + +Mmap Learn + [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=mmap STATS_HASH=compat STATS_KEY=${KEY_PVT1} + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_SPAM + [Teardown] Generic Teardown + +Mmap Relearn + [Setup] Statistics Setup @{ALIASES} STATS_BACKEND=mmap STATS_HASH=compat STATS_KEY=${KEY_PVT1} + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_SPAM + ${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_ham ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} success = true + ${result} = Scan Message With Rspamc ${MESSAGE} + Follow Rspamd Log + Should Contain ${result.stdout} BAYES_HAM + [Teardown] Generic Teardown diff --git a/test/functional/cases/symbol_depends.sh b/test/functional/cases/symbol_depends.sh deleted file mode 100644 index bcf718f7f..000000000 --- a/test/functional/cases/symbol_depends.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Test rspamd symbol dependencies - -. ${TEST_DIRNAME}/functions.sh - -sed -e 's|@@LUA_SCRIPT@@|${TESTDIR}/cases/deps.lua|' < \ - "$TEST_DIRNAME/configs/lua_test.conf" > \ - "$TMPDIR/rspamd.conf" -export RSPAMD_CONFIG="$TMPDIR/rspamd.conf" \ - STATSDIR=${TMPDIR} -run_rspamd - -run_rspamc symbols \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'DEP10'
\ No newline at end of file diff --git a/test/functional/cases/task_flags.sh b/test/functional/cases/task_flags.sh deleted file mode 100644 index 501d242cb..000000000 --- a/test/functional/cases/task_flags.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Test rspamd_task:get|set_flags functions - -. ${TEST_DIRNAME}/functions.sh - -sed -e 's|@@LUA_SCRIPT@@|${TESTDIR}/cases/flags.lua|' < \ - "$TEST_DIRNAME/configs/lua_test.conf" > \ - "$TMPDIR/rspamd.conf" -export RSPAMD_CONFIG="$TMPDIR/rspamd.conf" \ - STATSDIR=${TMPDIR} -run_rspamd - -run_rspamc symbols \ - "$TEST_DIRNAME/messages/spam_message.eml" -check_output 'skip,extended_urls,no_log,no_stat' - -run_rspamc stat -check_output 'Messages scanned: 0'
\ No newline at end of file |