From 0758fd8c4cc9b9698972e9782af51bbd5c1ff001 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 14 Aug 2019 09:05:34 +0100 Subject: [PATCH] [Test] Add more mime tests --- test/lua/unit/task.lua | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/lua/unit/task.lua b/test/lua/unit/task.lua index 3ec583043..e9fc9e7d5 100644 --- a/test/lua/unit/task.lua +++ b/test/lua/unit/task.lua @@ -111,4 +111,52 @@ Thank you, task:destroy() end) + test("Process mime nesting: message in multipart", function() + local msg = table.concat{ + hdrs, mpart, '\n', + '--XXX\n', + 'Content-Type: message/rfc822\n', '\n', hdrs, body , + '\n--XXX--\n', + } + + local res,task = rspamd_task.load_from_string(msg) + assert_true(res, "failed to load message") + task:process_message() + assert_rspamd_table_eq({ + actual = fun.totable(fun.map(function(u) + return u:get_host() + end, task:get_urls())), + + expect = { + 'evil.com', 'example.com' + }}) + + task:destroy() + end) + test("Process mime nesting: multipart message in multipart", function() + local msg = table.concat{ + hdrs, mpart, '\n', + '--XXX\n', + 'Content-Type: message/rfc822\n', '\n', hdrs, mpart, '\n', + + '--XXX\n', + body , + '\n--XXX--\n', + + '\n--XXX--\n', + } + local res,task = rspamd_task.load_from_string(msg) + assert_true(res, "failed to load message") + task:process_message() + assert_rspamd_table_eq({ + actual = fun.totable(fun.map(function(u) + return u:get_host() + end, task:get_urls())), + + expect = { + 'evil.com', 'example.com' + }}) + + task:destroy() + end) end) \ No newline at end of file -- 2.39.5