diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-11-12 15:53:56 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-11-19 12:44:14 +0000 |
commit | e9e0ee39de0c5ee1143edf495908820eb31e116a (patch) | |
tree | 32c4634a5560d75e63c90e032f92c58b5d004b76 /test/functional/lua/maps_kv.lua | |
parent | 3ec55e1bcb675fb2affcd4977e9517054c9a5342 (diff) | |
download | rspamd-e9e0ee39de0c5ee1143edf495908820eb31e116a.tar.gz rspamd-e9e0ee39de0c5ee1143edf495908820eb31e116a.zip |
[Test] Start write tests for external maps
Diffstat (limited to 'test/functional/lua/maps_kv.lua')
-rw-r--r-- | test/functional/lua/maps_kv.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/functional/lua/maps_kv.lua b/test/functional/lua/maps_kv.lua index a62d25ddd..0b1b535bf 100644 --- a/test/functional/lua/maps_kv.lua +++ b/test/functional/lua/maps_kv.lua @@ -1,5 +1,6 @@ local rspamd_ip = require 'rspamd_ip' local rspamd_logger = require 'rspamd_logger' +local lua_maps = require "lua_maps" local radix_map = rspamd_config:add_map ({ url = rspamd_env.RADIX_MAP, @@ -68,3 +69,26 @@ rspamd_config:register_symbol({ return true, 'no worry' end, }) + +local simple_ext_map = lua_maps.map_add_from_ucl({ + external = true, + backend = "http://localhost:18080/map-simple", + method = "body", + encode = "json", +}, '', 'external map') +rspamd_config:register_symbol({ + name = 'EXTERNAL_MAP', + score = 1.0, + callback = function(task) + local function cb(res, data, code) + if res then + task:insert_result('EXTERNAL_MAP', string.format('+%s', data)) + else + task:insert_result('EXTERNAL_MAP', string.format('-%s:%s', code, data)) + end + end + simple_ext_map:get_key({ + key = "value", + }, cb, task) + end, +}) |