]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Add tests for controller passwords
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Jul 2016 17:35:09 +0000 (18:35 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Jul 2016 17:35:09 +0000 (18:35 +0100)
test/functional/cases/103_password.robot [new file with mode: 0644]
test/functional/configs/password.conf [new file with mode: 0644]
test/functional/configs/trivial.conf

diff --git a/test/functional/cases/103_password.robot b/test/functional/cases/103_password.robot
new file mode 100644 (file)
index 0000000..93e55d6
--- /dev/null
@@ -0,0 +1,55 @@
+*** Settings ***
+Test Teardown  Generic Teardown
+Library         ${TESTDIR}/lib/rspamd.py
+Resource        ${TESTDIR}/lib/rspamd.robot
+Variables       ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG}       ${TESTDIR}/configs/password.conf
+${RSPAMD_SCOPE}  Test
+${PBKDF_PASSWORD}   "$1$nxnwqu5t6ruqfzb4h7bs47ogmdk9sb74$c8mbmcfyd6aic1sm48qzxuzkw4nhx6te6h7owgxz63bcd7fqu1dy"
+${CATENA_PASSWORD}  "$2$9dydyukfndmi8zzp7rbdsu43y7a3iucg$1nketaa9pjqwwzzjxogcrniphw4y5fanixudpwzza85tcb56yzub"
+
+*** Test Cases ***
+PASSWORD - PBKDF
+  [Setup]  Password Setup  ${PBKDF_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q1  stat
+  Should Contain  ${result.stdout}  Messages scanned:
+
+PASSWORD - PBKDF WRONG
+  [Setup]  Password Setup  ${PBKDF_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q1q1  stat
+  Should Contain  ${result.stdout}  Unauthorized  rc_nocheck=1
+
+PASSWORD - CATENA
+  [Setup]  Password Setup  ${CATENA_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q1  stat
+  Should Contain  ${result.stdout}  Messages scanned:
+
+
+PASSWORD - CATENA WRONG
+  [Setup]  Password Setup  ${CATENA_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q  stat
+  Should Contain  ${result.stdout}  Unauthorized  rc_nocheck=1
+
+PASSWORD - ENABLE
+  [Setup]  Password Setup  ${CATENA_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q2  stat_reset
+  Should Contain  ${result.stdout}  Messages scanned:
+
+PASSWORD - ENABLE WITH NORMAL
+  [Setup]  Password Setup  ${CATENA_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q1  stat_reset
+  Should Contain  ${result.stdout}  Unauthorized  rc_nocheck=1
+
+PASSWORD - ENABLE INCORRECT
+  [Setup]  Password Setup  ${CATENA_PASSWORD}
+  ${result} =  Run Rspamc  -h  ${LOCAL_ADDR}:${PORT_CONTROLLER}  -P  q2q2  stat_reset
+  Should Contain  ${result.stdout}  Unauthorized  rc_nocheck=1
+
+*** Keywords ***
+Password Setup
+  [Arguments]  ${PASSWORD}  ${ENABLE_PASSWORD}=q2
+  Set Test Variable  ${PASSWORD}
+  Set Test Variable  ${ENABLE_PASSWORD}
+  Generic Setup
\ No newline at end of file
diff --git a/test/functional/configs/password.conf b/test/functional/configs/password.conf
new file mode 100644 (file)
index 0000000..96688e9
--- /dev/null
@@ -0,0 +1,38 @@
+options = {
+       filters = ["spf", "dkim", "regexp"]
+       url_tld = "${TESTDIR}/../lua/unit/test_tld.dat"
+       pidfile = "${TMPDIR}/rspamd.pid"
+}
+logging = {
+       type = "file",
+       level = "debug"
+       filename = "${TMPDIR}/rspamd.log"
+}
+metric = {
+       name = "default",
+       actions = {
+               reject = 100500,
+       }
+       unknown_weight = 1
+}
+
+worker {
+       type = normal
+       bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL}
+       count = 1
+       keypair {
+               pubkey = "${KEY_PUB1}";
+               privkey = "${KEY_PVT1}";
+       }
+}
+worker {
+       type = controller
+       bind_socket = ${LOCAL_ADDR}:${PORT_CONTROLLER}
+       count = 1
+       keypair {
+               pubkey = "${KEY_PUB1}";
+               privkey = "${KEY_PVT1}";
+       }
+       password = ${PASSWORD};
+       enable_password = ${ENABLE_PASSWORD};
+}
\ No newline at end of file
index 9bc07fa5cca843d9839e6991ca5967ec34771f3c..9258df6b0c81e31777b6dde1eaee2b6781e09e0f 100644 (file)
@@ -24,4 +24,4 @@ worker {
                pubkey = "${KEY_PUB1}";
                privkey = "${KEY_PVT1}";
        }
-}
+}
\ No newline at end of file