]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add simple test for proxying
authorAndrew Lewis <nerf@judo.za.org>
Tue, 9 Aug 2016 12:58:33 +0000 (13:58 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 9 Aug 2016 12:58:33 +0000 (13:58 +0100)
test/functional/cases/140_proxy.robot [new file with mode: 0644]
test/functional/configs/proxy.conf [new file with mode: 0644]
test/functional/lib/vars.py

diff --git a/test/functional/cases/140_proxy.robot b/test/functional/cases/140_proxy.robot
new file mode 100644 (file)
index 0000000..6ad3086
--- /dev/null
@@ -0,0 +1,38 @@
+*** Settings ***
+Suite Setup     Proxy Setup
+Suite Teardown  Proxy Teardown
+Library         ${TESTDIR}/lib/rspamd.py
+Resource        ${TESTDIR}/lib/rspamd.robot
+Variables       ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${LUA_SCRIPT}   ${TESTDIR}/lua/simple.lua
+${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
+
+*** Test Cases ***
+Scan Message
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_PROXY}  -p  ${MESSAGE}
+  ${PROXY_LOGPOS} =  Log Logs  ${PROXY_TMPDIR}/rspamd.log  ${PROXY_LOGPOS}
+  Set Suite Variable  ${PROXY_LOGPOS}
+  ${SLAVE_LOGPOS} =  Log Logs  ${SLAVE_TMPDIR}/rspamd.log  ${SLAVE_LOGPOS}
+  Set Suite Variable  ${SLAVE_LOGPOS}
+  Run Keyword If  ${result.rc} != 0  Log  ${result.stderr}
+  Should Contain  ${result.stdout}  SIMPLE_TEST
+  Should Be Equal As Integers  ${result.rc}  0
+
+*** Keywords ***
+Proxy Setup
+  &{d} =  Run Rspamd  CONFIG=${TESTDIR}/configs/lua_test.conf
+  Set Suite Variable  ${SLAVE_LOGPOS}  &{d}[RSPAMD_LOGPOS]
+  Set Suite Variable  ${SLAVE_PID}  &{d}[RSPAMD_PID]
+  Set Suite Variable  ${SLAVE_TMPDIR}  &{d}[TMPDIR]
+  &{d} =  Run Rspamd  CONFIG=${TESTDIR}/configs/proxy.conf
+  Set Suite Variable  ${PROXY_LOGPOS}  &{d}[RSPAMD_LOGPOS]
+  Set Suite Variable  ${PROXY_PID}  &{d}[RSPAMD_PID]
+  Set Suite Variable  ${PROXY_TMPDIR}  &{d}[TMPDIR]
+
+Proxy Teardown
+  Shutdown Process With Children  ${PROXY_PID}
+  Shutdown Process With Children  ${SLAVE_PID}
+  Cleanup Temporary Directory  ${PROXY_TMPDIR}
+  Cleanup Temporary Directory  ${SLAVE_TMPDIR}
diff --git a/test/functional/configs/proxy.conf b/test/functional/configs/proxy.conf
new file mode 100644 (file)
index 0000000..5f40d15
--- /dev/null
@@ -0,0 +1,18 @@
+options = {
+       filters = "spf"
+       pidfile = "${TMPDIR}/rspamd.pid"
+}
+logging = {
+       type = "file",
+       level = "debug"
+       filename = "${TMPDIR}/rspamd.log"
+}
+worker "rspamd_proxy" {
+    bind_socket = "${LOCAL_ADDR}:${PORT_PROXY}";
+    upstream {
+        name = "${LOCAL_ADDR}";
+        default = yes;
+        hosts = "${LOCAL_ADDR}:${PORT_NORMAL}";
+    }
+    count = 1;
+}
index 170b7c5c3905884bd87524b183475b2a45dd1eeb..f260dc1b4dcadf892a5dcf6bc4985ecdec1920ee 100644 (file)
@@ -4,6 +4,7 @@ LOCAL_ADDR = '127.0.0.1'
 PORT_CONTROLLER = 56790
 PORT_FUZZY = 56791
 PORT_NORMAL = 56789
+PORT_PROXY = 56795
 REDIS_ADDR = '127.0.0.1'
 REDIS_PORT = 56379
 RSPAMD_GROUP = 'nogroup'