diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2019-01-16 15:07:34 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2019-01-17 11:32:00 +0300 |
commit | e481f8514ade0e8a3a5750c22c1fda9cffaea3fe (patch) | |
tree | 3c91e065fc9f6fb14b5b07e9650dbe66209b5f8c /test | |
parent | ae8f1997198be36340efb8a1d291e0339b1486c3 (diff) | |
download | rspamd-e481f8514ade0e8a3a5750c22c1fda9cffaea3fe.tar.gz rspamd-e481f8514ade0e8a3a5750c22c1fda9cffaea3fe.zip |
[Test] Add task:get_from(['mime']) test
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/cases/104_get_from.robot | 53 | ||||
-rw-r--r-- | test/functional/configs/lua_script.conf | 25 | ||||
-rw-r--r-- | test/functional/lua/get_from.lua | 8 | ||||
-rw-r--r-- | test/functional/messages/from/from.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_comment.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_dn.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_dn_base64.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_dn_comment.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_quoted_dn.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_quoted_dn_comment.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_quoted_dn_middle.eml | 2 | ||||
-rw-r--r-- | test/functional/messages/from/from_quoted_dn_middle_inner.eml | 2 |
12 files changed, 104 insertions, 0 deletions
diff --git a/test/functional/cases/104_get_from.robot b/test/functional/cases/104_get_from.robot new file mode 100644 index 000000000..a81dec559 --- /dev/null +++ b/test/functional/cases/104_get_from.robot @@ -0,0 +1,53 @@ +*** Settings *** +Suite Setup Generic Setup +Suite Teardown Simple Teardown +Library ${TESTDIR}/lib/rspamd.py +Resource ${TESTDIR}/lib/rspamd.robot +Variables ${TESTDIR}/lib/vars.py + +*** Variables *** +${CONFIG} ${TESTDIR}/configs/lua_script.conf +${LUA_SCRIPT} ${TESTDIR}/lua/get_from.lua +${RSPAMD_SCOPE} Suite + +${SYMBOL} GET_FROM (0.00) +${SYMBOL1} ${SYMBOL}[,user@example.org,user,example.org] +${SYMBOL2} ${SYMBOL}[First Last,user@example.org,user,example.org] +${SYMBOL3} ${SYMBOL}[First M. Last,user@example.org,user,example.org] + +*** Test Cases *** +task:get_from('mime') - address only + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from.eml + Check Rspamc ${result} ${SYMBOL1} + +task:get_from('mime') - comment + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_comment.eml + Check Rspamc ${result} ${SYMBOL1} + +task:get_from('mime') - display name + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_dn.eml + Check Rspamc ${result} ${SYMBOL2} + +task:get_from('mime') - display name Base64 + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_dn_base64.eml + Check Rspamc ${result} ${SYMBOL}[Кириллица,user@example.org,user,example.org] + +task:get_from('mime') - display name and comment + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_dn_comment.eml + Check Rspamc ${result} ${SYMBOL2} + +task:get_from('mime') - quoted display name + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_quoted_dn.eml + Check Rspamc ${result} ${SYMBOL3} + +task:get_from('mime') - quoted display name and comment + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_quoted_dn_comment.eml + Check Rspamc ${result} ${SYMBOL3} + +task:get_from('mime') - quoted in the middle of DN (outer spaces) + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_quoted_dn_middle.eml + Check Rspamc ${result} ${SYMBOL3} + +task:get_from('mime') - quoted in the middle of DN (inner spaces) + ${result} = Scan Message With Rspamc ${TESTDIR}/messages/from/from_quoted_dn_middle_inner.eml + Check Rspamc ${result} ${SYMBOL3} diff --git a/test/functional/configs/lua_script.conf b/test/functional/configs/lua_script.conf new file mode 100644 index 000000000..2bde672fe --- /dev/null +++ b/test/functional/configs/lua_script.conf @@ -0,0 +1,25 @@ +options = { + pidfile = "${TMPDIR}/rspamd.pid" +} +logging = { + type = "file", + level = "debug" + filename = "${TMPDIR}/rspamd.log" +} + +worker { + type = normal + bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL} + count = 1 + task_timeout = 60s; +} +worker { + type = controller + bind_socket = ${LOCAL_ADDR}:${PORT_CONTROLLER} + count = 1 + secure_ip = ["127.0.0.1", "::1"]; + stats_path = "${TMPDIR}/stats.ucl" +} + +lua = "${TESTDIR}/lua/test_coverage.lua"; +lua = ${LUA_SCRIPT}; diff --git a/test/functional/lua/get_from.lua b/test/functional/lua/get_from.lua new file mode 100644 index 000000000..4e3267b41 --- /dev/null +++ b/test/functional/lua/get_from.lua @@ -0,0 +1,8 @@ +rspamd_config:register_symbol({ + name = 'SIMPLE_TEST', + score = 1.0, + callback = function(task) + local a = task:get_from('mime')[1] + task:insert_result('GET_FROM', 0.0, a.name .. ',' .. a.addr .. ',' .. a.user .. ',' .. a.domain) + end +}) diff --git a/test/functional/messages/from/from.eml b/test/functional/messages/from/from.eml new file mode 100644 index 000000000..20c2b1bd8 --- /dev/null +++ b/test/functional/messages/from/from.eml @@ -0,0 +1,2 @@ +From: user@example.org + diff --git a/test/functional/messages/from/from_comment.eml b/test/functional/messages/from/from_comment.eml new file mode 100644 index 000000000..235ccf1e9 --- /dev/null +++ b/test/functional/messages/from/from_comment.eml @@ -0,0 +1,2 @@ +From: user@example.org (Comment text) + diff --git a/test/functional/messages/from/from_dn.eml b/test/functional/messages/from/from_dn.eml new file mode 100644 index 000000000..fd714c2b3 --- /dev/null +++ b/test/functional/messages/from/from_dn.eml @@ -0,0 +1,2 @@ +From: First Last <user@example.org> + diff --git a/test/functional/messages/from/from_dn_base64.eml b/test/functional/messages/from/from_dn_base64.eml new file mode 100644 index 000000000..e4fdbf2cf --- /dev/null +++ b/test/functional/messages/from/from_dn_base64.eml @@ -0,0 +1,2 @@ +From: =?UTF-8?B?0JrQuNGA0LjQu9C70LjRhtCw?= <user@example.org> + diff --git a/test/functional/messages/from/from_dn_comment.eml b/test/functional/messages/from/from_dn_comment.eml new file mode 100644 index 000000000..5f8b339d4 --- /dev/null +++ b/test/functional/messages/from/from_dn_comment.eml @@ -0,0 +1,2 @@ +From: First Last <user@example.org> (Comment text) + diff --git a/test/functional/messages/from/from_quoted_dn.eml b/test/functional/messages/from/from_quoted_dn.eml new file mode 100644 index 000000000..8e0d01ef2 --- /dev/null +++ b/test/functional/messages/from/from_quoted_dn.eml @@ -0,0 +1,2 @@ +From: "First M. Last" <user@example.org> + diff --git a/test/functional/messages/from/from_quoted_dn_comment.eml b/test/functional/messages/from/from_quoted_dn_comment.eml new file mode 100644 index 000000000..eddba68f4 --- /dev/null +++ b/test/functional/messages/from/from_quoted_dn_comment.eml @@ -0,0 +1,2 @@ +From: "First M. Last" <user@example.org> (Comment text) + diff --git a/test/functional/messages/from/from_quoted_dn_middle.eml b/test/functional/messages/from/from_quoted_dn_middle.eml new file mode 100644 index 000000000..98ddac4ce --- /dev/null +++ b/test/functional/messages/from/from_quoted_dn_middle.eml @@ -0,0 +1,2 @@ +From: First "M." Last <user@example.org> + diff --git a/test/functional/messages/from/from_quoted_dn_middle_inner.eml b/test/functional/messages/from/from_quoted_dn_middle_inner.eml new file mode 100644 index 000000000..4e7f3630f --- /dev/null +++ b/test/functional/messages/from/from_quoted_dn_middle_inner.eml @@ -0,0 +1,2 @@ +From: First" M. "Last <user@example.org> + |