From: Vsevolod Stakhov Date: Thu, 28 Jul 2016 17:35:09 +0000 (+0100) Subject: [Test] Add tests for controller passwords X-Git-Tag: 1.3.1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ea6d39d57cd6147409e4b6ab8375fbbd4e77680;p=thirdparty%2Frspamd.git [Test] Add tests for controller passwords --- diff --git a/test/functional/cases/103_password.robot b/test/functional/cases/103_password.robot new file mode 100644 index 0000000000..93e55d683c --- /dev/null +++ b/test/functional/cases/103_password.robot @@ -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 index 0000000000..96688e996a --- /dev/null +++ b/test/functional/configs/password.conf @@ -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 diff --git a/test/functional/configs/trivial.conf b/test/functional/configs/trivial.conf index 9bc07fa5cc..9258df6b0c 100644 --- a/test/functional/configs/trivial.conf +++ b/test/functional/configs/trivial.conf @@ -24,4 +24,4 @@ worker { pubkey = "${KEY_PUB1}"; privkey = "${KEY_PVT1}"; } -} +} \ No newline at end of file