aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua/rspamd_test_helper.lua
blob: 4d58d261a516951bcd973793286cc1cbe372aa06 (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
45
46
local ffi = require "ffi"
local cfg = rspamd_config

ffi.cdef[[
void rspamd_url_init (const char *tld_file);
]]
local exports = {}

function exports.init_url_parser(file)
  if not file then
    local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1")
    file = string.format('%s/unit/%s', test_dir, "test_tld.dat")
  end

  ffi.C.rspamd_url_init(file)
end

function exports.default_config()
  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
    }
  }

  return config
end

return exports