Expect Symbol With Option ANY_A hello3
Expect Symbol With Option ANY_A hello1
Expect Symbol With Option ANY_A hello2
+
+External Maps Simple
+ Scan File ${MESSAGE} Settings={symbols_enabled = [EXTERNAL_MAP]}
+ Expect Symbol With Exact Options EXTERNAL_MAP +hello
\ No newline at end of file
*** Settings ***
-Suite Setup Rspamd Redis Setup
+Suite Setup Multi Setup
Suite Teardown Rspamd Redis Teardown
Library ${RSPAMD_TESTDIR}/lib/rspamd.py
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
${RSPAMD_RADIX_MAP} ${RSPAMD_TESTDIR}/configs/maps/ip2.list
${RSPAMD_REGEXP_MAP} ${RSPAMD_TESTDIR}/configs/maps/regexp.list
${RSPAMD_SCOPE} Suite
+
+*** Keywords ***
+Multi Setup
+ Run Redis
+ Run Dummy Http
+ Run Dummy Https
+ Rspamd Setup
+
+Multi Teardown
+ Rspamd Teardown
+ ${http_pid} = Get File /tmp/dummy_http.pid
+ Shutdown Process With Children ${http_pid}
+ ${https_pid} = Get File /tmp/dummy_https.pid
+ Shutdown Process With Children ${https_pid}
+ Redis Teardown
+
+Run Dummy Http
+ ${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py
+ Wait Until Created /tmp/dummy_http.pid
+
+Run Dummy Https
+ ${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_https.py ${RSPAMD_TESTDIR}/util/server.pem
+ Wait Until Created /tmp/dummy_https.pid
\ No newline at end of file
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,
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,
+})
if self.path == "/content-length":
self.send_header("Content-Length", str(len(response)))
+ if self.path == "/map-simple":
+ response = "hello"
+
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write(response)