Browse Source

Merge pull request #2715 from moisseev/test

[Test] Add task:get_from(['mime']) test
tags/1.9.0
Vsevolod Stakhov 5 years ago
parent
commit
497ac2e3ef
No account linked to committer's email address

+ 53
- 0
test/functional/cases/104_get_from.robot View File

@@ -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}

+ 25
- 0
test/functional/configs/lua_script.conf View File

@@ -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};

+ 8
- 0
test/functional/lua/get_from.lua View File

@@ -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
})

+ 2
- 0
test/functional/messages/from/from.eml View File

@@ -0,0 +1,2 @@
From: user@example.org


+ 2
- 0
test/functional/messages/from/from_comment.eml View File

@@ -0,0 +1,2 @@
From: user@example.org (Comment text)


+ 2
- 0
test/functional/messages/from/from_dn.eml View File

@@ -0,0 +1,2 @@
From: First Last <user@example.org>


+ 2
- 0
test/functional/messages/from/from_dn_base64.eml View File

@@ -0,0 +1,2 @@
From: =?UTF-8?B?0JrQuNGA0LjQu9C70LjRhtCw?= <user@example.org>


+ 2
- 0
test/functional/messages/from/from_dn_comment.eml View File

@@ -0,0 +1,2 @@
From: First Last <user@example.org> (Comment text)


+ 2
- 0
test/functional/messages/from/from_quoted_dn.eml View File

@@ -0,0 +1,2 @@
From: "First M. Last" <user@example.org>


+ 2
- 0
test/functional/messages/from/from_quoted_dn_comment.eml View File

@@ -0,0 +1,2 @@
From: "First M. Last" <user@example.org> (Comment text)


+ 2
- 0
test/functional/messages/from/from_quoted_dn_middle.eml View File

@@ -0,0 +1,2 @@
From: First "M." Last <user@example.org>


+ 2
- 0
test/functional/messages/from/from_quoted_dn_middle_inner.eml View File

@@ -0,0 +1,2 @@
From: First" M. "Last <user@example.org>


Loading…
Cancel
Save