From: Vsevolod Stakhov Date: Sun, 27 Nov 2022 23:09:55 +0000 (+0000) Subject: [Test] Add test case for settings in the external map X-Git-Tag: 3.5~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=df56dd4dc0b286dd8b28ffe05ca5b4722caee89d;p=rspamd.git [Test] Add test case for settings in the external map --- diff --git a/test/functional/cases/108_settings.robot b/test/functional/cases/108_settings.robot index e7f4213a5..240dd6e66 100644 --- a/test/functional/cases/108_settings.robot +++ b/test/functional/cases/108_settings.robot @@ -246,6 +246,10 @@ SETTINGS ID - VIRTUAL DEP Do Not Expect Symbol SIMPLE_POST Do Not Expect Symbol SIMPLE_PRE +SETTINGS ID - EXTERNAL MAP + Scan File ${MESSAGE} Settings-Id=external + Expect Symbol EXTERNAL_SETTINGS + PRIORITY Scan File ${MESSAGE_PRIORITY} Settings-Id=id_virtual_group From=user@test.com Expect Symbol PRIORITY_2 @@ -255,8 +259,15 @@ PRIORITY Settings Setup Copy File ${RSPAMD_TESTDIR}/data/bayes.spam.sqlite3 /tmp/bayes.spam.sqlite3 Copy File ${RSPAMD_TESTDIR}/data/bayes.ham.sqlite3 /tmp/bayes.ham.sqlite3 + Run Dummy Http Rspamd Setup Settings Teardown Rspamd Teardown + ${http_pid} = Get File /tmp/dummy_http.pid + Shutdown Process With Children ${http_pid} Remove Files /tmp/bayes.spam.sqlite3 /tmp/bayes.ham.sqlite3 + +Run Dummy Http + ${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py + Wait Until Created /tmp/dummy_http.pid diff --git a/test/functional/configs/settings.conf b/test/functional/configs/settings.conf index b7166ab3b..7bcc58a1d 100644 --- a/test/functional/configs/settings.conf +++ b/test/functional/configs/settings.conf @@ -82,6 +82,22 @@ settings { groups_enabled = []; } } + + external { + disabled = true + external_map = { + map = { + backend = "http://127.0.0.1:18080/settings"; + external = true; + method = "body"; + encode = "json"; + } + selector = "id('from');from('mime')"; + } + register_symbols = { + EXTERNAL_SETTINGS = { score = 1.0 } + } + } } classifier { diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py index 92b538845..8de1b027b 100755 --- a/test/functional/util/dummy_http.py +++ b/test/functional/util/dummy_http.py @@ -88,7 +88,7 @@ class MyHandler(http.server.BaseHTTPRequestHandler): if self.path == "/map-simple": response = b"hello map" if self.path == "/settings": - response = b"{\"actions\": { \"reject\": 1.0}}" + response = b"{\"actions\": { \"reject\": 1.0}, \"symbols\": { \"EXTERNAL_SETTINGS\": 1.0 }}" content_type = "application/json" self.send_header("Content-Length", str(len(response)))