aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-18 10:41:21 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-18 10:41:21 +0100
commit247bc030c0430431153db306af90a70994f08c79 (patch)
treeb4b085ddf89354640f6e8304a3788524dbb5b250 /test
parent2d6d215df32c129b15502efdf5ec3c21c3d167ff (diff)
downloadrspamd-247bc030c0430431153db306af90a70994f08c79.tar.gz
rspamd-247bc030c0430431153db306af90a70994f08c79.zip
[Test] Test for regexps in {sa_body} and urls with newlines
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/260_regex.robot37
-rw-r--r--test/functional/lua/regex_test.lua12
-rw-r--r--test/functional/messages/newlines.eml13
3 files changed, 62 insertions, 0 deletions
diff --git a/test/functional/cases/260_regex.robot b/test/functional/cases/260_regex.robot
new file mode 100644
index 000000000..24bdca301
--- /dev/null
+++ b/test/functional/cases/260_regex.robot
@@ -0,0 +1,37 @@
+*** Settings ***
+Test Setup Regex Setup
+Test Teardown Regex Teardown
+Library ${TESTDIR}/lib/rspamd.py
+Resource ${TESTDIR}/lib/rspamd.robot
+Variables ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG} ${TESTDIR}/configs/plugins.conf
+${MESSAGE} ${TESTDIR}/messages/newlines.eml
+${UTF_MESSAGE} ${TESTDIR}/messages/utf.eml
+${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat
+${RSPAMD_SCOPE} Test
+
+
+*** Test Cases ***
+Newlines
+ ${result} = Scan Message With Rspamc ${MESSAGE}
+ Check Rspamc ${result} SA_BODY_WORD
+ Check Rspamc ${result} SA_BODY_WORD_WITH_SPACE
+ Check Rspamc ${result} SA_BODY_WORD_WITH_NEWLINE inverse=true
+ Check Rspamc ${result} SA_BODY_WORD_WITH_SPACE_BOUNDARIES
+ Check Rspamc ${result} SA_BODY_WORD_WITH_SPACE_BOUNDARIES_2
+ Check Rspamc ${result} SA_BODY_WORD_WITH_SPACE_BOUNDARIES_3
+ Check Rspamc ${result} https://google.com/maps/
+ Check Rspamc ${result} https://www.google.com/search?q\=hello world&oq\=hello world&aqs\=chrome..69i57j0l5.3045j0j7&sourceid\=chrome&ie\=UTF-8
+ Check Rspamc ${result} https://github.com/google/sanitizers/wiki/AddressSanitizer
+
+
+*** Keywords ***
+Regex Setup
+ ${PLUGIN_CONFIG} = Get File ${TESTDIR}/configs/regexp.conf
+ Set Suite Variable ${PLUGIN_CONFIG}
+ Generic Setup PLUGIN_CONFIG
+
+Regex Teardown
+ Normal Teardown
diff --git a/test/functional/lua/regex_test.lua b/test/functional/lua/regex_test.lua
new file mode 100644
index 000000000..01f0e226a
--- /dev/null
+++ b/test/functional/lua/regex_test.lua
@@ -0,0 +1,12 @@
+local function get_urls(task)
+ local urls = task:get_urls()
+ for _, u in ipairs(urls) do
+ task:insert_result('FOUND_URL', 1.0, tostring(u))
+ end
+end
+
+rspamd_config:register_symbol({
+ name = 'SIMPLE',
+ score = 1.0,
+ callback = get_urls
+})
diff --git a/test/functional/messages/newlines.eml b/test/functional/messages/newlines.eml
new file mode 100644
index 000000000..090d180e1
--- /dev/null
+++ b/test/functional/messages/newlines.eml
@@ -0,0 +1,13 @@
+Content-Type: text/plain
+
+this is the word separated with newline:
+hello
+world
+
+this is the url separated with newline: <https://github.com/google/sanitizers/wi
+ki/AddressSanitizer>
+<https://www.google.com/search?q=hello+world&oq=hello+world&aqs=chro
+me..69i57j0l5.3045j0j7&sourceid=chrome&ie=UTF-8>
+<https://google.com
+/maps/> click here
+