]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add task:get_from(['mime']) test 2715/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Wed, 16 Jan 2019 12:07:34 +0000 (15:07 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Thu, 17 Jan 2019 08:32:00 +0000 (11:32 +0300)
12 files changed:
test/functional/cases/104_get_from.robot [new file with mode: 0644]
test/functional/configs/lua_script.conf [new file with mode: 0644]
test/functional/lua/get_from.lua [new file with mode: 0644]
test/functional/messages/from/from.eml [new file with mode: 0644]
test/functional/messages/from/from_comment.eml [new file with mode: 0644]
test/functional/messages/from/from_dn.eml [new file with mode: 0644]
test/functional/messages/from/from_dn_base64.eml [new file with mode: 0644]
test/functional/messages/from/from_dn_comment.eml [new file with mode: 0644]
test/functional/messages/from/from_quoted_dn.eml [new file with mode: 0644]
test/functional/messages/from/from_quoted_dn_comment.eml [new file with mode: 0644]
test/functional/messages/from/from_quoted_dn_middle.eml [new file with mode: 0644]
test/functional/messages/from/from_quoted_dn_middle_inner.eml [new file with mode: 0644]

diff --git a/test/functional/cases/104_get_from.robot b/test/functional/cases/104_get_from.robot
new file mode 100644 (file)
index 0000000..a81dec5
--- /dev/null
@@ -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 (file)
index 0000000..2bde672
--- /dev/null
@@ -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 (file)
index 0000000..4e3267b
--- /dev/null
@@ -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 (file)
index 0000000..20c2b1b
--- /dev/null
@@ -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 (file)
index 0000000..235ccf1
--- /dev/null
@@ -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 (file)
index 0000000..fd714c2
--- /dev/null
@@ -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 (file)
index 0000000..e4fdbf2
--- /dev/null
@@ -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 (file)
index 0000000..5f8b339
--- /dev/null
@@ -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 (file)
index 0000000..8e0d01e
--- /dev/null
@@ -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 (file)
index 0000000..eddba68
--- /dev/null
@@ -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 (file)
index 0000000..98ddac4
--- /dev/null
@@ -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 (file)
index 0000000..4e7f363
--- /dev/null
@@ -0,0 +1,2 @@
+From: First" M. "Last <user@example.org>
+