commit 0758fd8: [Test] Add more mime tests

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Aug 14 09:00:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-14 09:05:34 +0100
URL: https://github.com/rspamd/rspamd/commit/0758fd8c4cc9b9698972e9782af51bbd5c1ff001

[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


More information about the Commits mailing list