summaryrefslogtreecommitdiffstats
path: root/test/functional/lua/settings.lua
blob: 384c68e136a82dee55864315e55d8e7c79c60353 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
rspamd_config:register_symbol({
  name = 'SIMPLE_PRE',
  score = 1.0,
  priority = 9, -- after settings
  group = 'a',
  type = 'prefilter',
  callback = function()
    return true, 'Fires always'
  end
})

rspamd_config:register_symbol({
  name = 'SIMPLE_POST',
  score = 1.0,
  type = 'postfilter',
  group = 'c',
  callback = function()
    return true, 'Fires always'
  end
})

local id = rspamd_config:register_symbol({
  name = 'SIMPLE_TEST',
  score = 1.0,
  group = 'b',
  callback = function(task)
    task:insert_result('SIMPLE_VIRTUAL', 1.0)
    task:insert_result('SIMPLE_VIRTUAL1', 1.0)
    return true, 'Fires always'
  end
})

rspamd_config:register_symbol({
  name = 'SIMPLE_VIRTUAL',
  type = 'virtual',
  score = 1.0,
  group = 'vg',
  parent = id,
})

rspamd_config:register_symbol({
  name = 'SIMPLE_VIRTUAL1',
  type = 'virtual',
  forbidden_ids = 'id_virtual,id_virtual_group',
  allowed_ids = 'id_virtual1',
  score = 1.0,
  group = 'vg',
  parent = id,
})

id = rspamd_config:register_symbol({
  name = 'DEP_REAL',
  callback = function(task)
    task:insert_result('DEP_VIRTUAL', 1.0)
    return true
  end,
  score = 1.0,
})

rspamd_config:register_symbol({
  name = 'DEP_VIRTUAL',
  parent = id,
  type = 'virtual',
  allowed_ids = 'id_virtual1',
  score = 1.0,
})

rspamd_config:register_dependency('DEP_VIRTUAL', 'EXPLICIT_VIRTUAL1')