mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
tests: added check for IP banning subsystem
This commit is contained in:
@@ -6,7 +6,8 @@ EXTRA_DIST = ca-key.pem ca.pem common.sh server-cert.pem server-key.pem test1.co
|
||||
test-user-group-cert-no-pass.config docker-common.sh test-cookie-timeout.config \
|
||||
test-cookie-timeout-2.config user-config-explicit/test test-explicit-ip.config \
|
||||
test-explicit-ip user-config-explicit/test2 user-config-explicit/test3 \
|
||||
user-config-explicit/test4 test-pass-opt-cert.config test-gssapi.config
|
||||
user-config-explicit/test4 test-pass-opt-cert.config test-gssapi.config \
|
||||
test-ban.config
|
||||
|
||||
SUBDIRS = docker-ocserv docker-kerberos
|
||||
|
||||
@@ -14,13 +15,13 @@ dist_check_SCRIPTS = test-pass test-pass-cert test-cert test-iroute test-pass-sc
|
||||
test-multi-cookie test-stress full-test test-group-pass test-pass-group-cert \
|
||||
ocpasswd-test test-pass-group-cert-no-pass unix-test test-pass-opt-cert \
|
||||
test-cookie-timeout test-cookie-timeout-2 radius-test test-explicit-ip \
|
||||
radius-test test-gssapi kerberos-test pam-test
|
||||
radius-test test-gssapi kerberos-test pam-test test-ban
|
||||
|
||||
TESTS = test-pass test-pass-cert test-cert test-iroute test-pass-script \
|
||||
test-multi-cookie full-test test-group-pass test-pass-group-cert \
|
||||
ocpasswd-test test-pass-group-cert-no-pass unix-test test-pass-opt-cert \
|
||||
test-cookie-timeout test-cookie-timeout-2 test-explicit-ip radius-test \
|
||||
test-gssapi kerberos-test pam-test
|
||||
test-gssapi kerberos-test pam-test test-ban
|
||||
|
||||
TESTS_ENVIRONMENT = srcdir="$(srcdir)" \
|
||||
top_builddir="$(top_builddir)"
|
||||
|
||||
79
tests/test-ban
Executable file
79
tests/test-ban
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2013 Red Hat
|
||||
#
|
||||
# This file is part of ocserv.
|
||||
#
|
||||
# ocserv is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# ocserv is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GnuTLS; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
SERV="${SERV:-../src/ocserv}"
|
||||
srcdir=${srcdir:-.}
|
||||
PORT=4497
|
||||
|
||||
. `dirname $0`/common.sh
|
||||
|
||||
echo "Testing whether ban operates as expected... "
|
||||
|
||||
launch_server -d 1 -f -c ${srcdir}/test-ban.config & PID=$!
|
||||
wait_server $PID
|
||||
|
||||
echo "Connecting with wrong password 5 times... "
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
|
||||
echo ""
|
||||
echo "Connecting with correct password... "
|
||||
eval `echo "test" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3`
|
||||
|
||||
if [ -n "$COOKIE" ];then
|
||||
fail $PID "Obtained cookie although should have been banned"
|
||||
fi
|
||||
|
||||
#echo "Cookie: $COOKIE"
|
||||
sleep 25
|
||||
echo ""
|
||||
|
||||
echo "Connecting with correct password after ban time... "
|
||||
eval `echo "test" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3`
|
||||
|
||||
if [ -z "$COOKIE" ];then
|
||||
fail $PID "Could not obtain cookie even though ban should be lifted"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Checking ban reset time... "
|
||||
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
sleep 11
|
||||
echo "notest" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3
|
||||
|
||||
echo ""
|
||||
echo "Connecting with correct password after ban reset time... "
|
||||
eval `echo "test" | openconnect --passwd-on-stdin -q localhost:$PORT -u test --authenticate --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3`
|
||||
|
||||
if [ -z "$COOKIE" ];then
|
||||
fail $PID "Could not obtain cookie even though ban should be lifted"
|
||||
fi
|
||||
|
||||
kill $PID
|
||||
wait
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user