]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add test case for settings in the external map
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 27 Nov 2022 23:09:55 +0000 (23:09 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 27 Nov 2022 23:09:55 +0000 (23:09 +0000)
test/functional/cases/108_settings.robot
test/functional/configs/settings.conf
test/functional/util/dummy_http.py

index e7f4213a5bbe7db37976888392690763ab5a0f0e..240dd6e66f369991d19b14b88f753ef038eb5abf 100644 (file)
@@ -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
index b7166ab3b7348caecdfd58af58f9204074efb246..7bcc58a1d424b15eb66f0eaaf68112595b67f549 100644 (file)
@@ -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 {
index 92b538845c2a1b861d8946f7fafb56206023552b..8de1b027bb61f85507c5d6a658d2fe9255d1e778 100755 (executable)
@@ -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)))