aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua/unit/task.lua
blob: ed61fb3c5695ce09ac1642af1aebb1f2e83e4fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 = 'debug'
    },
    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)