aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-18 15:07:54 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-18 15:07:54 +0100
commit0bb21d70a5b53280cd8cdbec20fa43261efc59ca (patch)
treea188cc99e1ecaa03ad22c05ab14e7b09d6ea1bd8 /test
parentbc6b7ac2ea6e76f2c533ed281316c9d5fc531583 (diff)
downloadrspamd-0bb21d70a5b53280cd8cdbec20fa43261efc59ca.tar.gz
rspamd-0bb21d70a5b53280cd8cdbec20fa43261efc59ca.zip
Add a simple unit test of task processing.
Diffstat (limited to 'test')
-rw-r--r--test/lua/unit/task.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/lua/unit/task.lua b/test/lua/unit/task.lua
new file mode 100644
index 000000000..c5528f7f6
--- /dev/null
+++ b/test/lua/unit/task.lua
@@ -0,0 +1,44 @@
+context("Task processing", function()
+ local ffi = require("ffi")
+ local rspamd_util = require("rspamd_util")
+ local logger = require("rspamd_logger")
+ local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1")
+
+ local tld_file = string.format('%s/%s', test_dir, "test_tld.dat")
+ local config = {
+ options = {
+ filters = {'spf', 'dkim', 'regexp'},
+ url_tld = tld_file,
+ dns = {
+ nameserver = {'8.8.8.8'}
+ },
+ },
+ logging = {
+ type = 'console',
+ level = 'info'
+ },
+ metric = {
+ name = 'default',
+ actions = {
+ reject = 100500,
+ },
+ unknown_weight = 1
+ }
+ }
+
+ test("Process a simple task", function()
+ local cfg = rspamd_util.config_from_ucl(config)
+ assert_not_nil(cfg)
+
+ local msg = [[
+From: <>
+To: <nobody@example.com>
+Subject: test
+Content-Type: text/plain
+
+Test.
+]]
+ local obj = rspamd_util.process_message(cfg, msg)
+ print(logger.slog("result: %1", obj))
+ end)
+end) \ No newline at end of file