mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-12 01:26:48 +08:00
Test whether the connect and disconnect scripts have been called.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
EXTRA_DIST = ca-key.pem ca.pem common.sh server-cert.pem server-key.pem test1.config \
|
EXTRA_DIST = ca-key.pem ca.pem common.sh server-cert.pem server-key.pem test1.config \
|
||||||
test1.passwd test-user-cert.config user-cert.pem user-key.pem test3.config test-iroute.config \
|
test1.passwd test-user-cert.config user-cert.pem user-key.pem test3.config test-iroute.config \
|
||||||
user-config/test test-pass-script.config test-multi-cookie.config test-pam.config \
|
user-config/test test-pass-script.config test-multi-cookie.config test-pam.config \
|
||||||
test-stress.config user-cert-wrong.pem
|
test-stress.config user-cert-wrong.pem connect-script
|
||||||
|
|
||||||
dist_check_SCRIPTS = test-pass test-pass-cert test-cert test-iroute test-pass-script \
|
dist_check_SCRIPTS = test-pass test-pass-cert test-cert test-iroute test-pass-script \
|
||||||
test-multi-cookie test-pam test-stress
|
test-multi-cookie test-pam test-stress
|
||||||
|
|||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#echo $USERNAME : $REASON : $DEVICE
|
||||||
|
|
||||||
|
case "$REASON" in
|
||||||
|
connect)
|
||||||
|
echo > connect.ok
|
||||||
|
;;
|
||||||
|
disconnect)
|
||||||
|
if ! test -z "$DEVICE";then
|
||||||
|
ifconfig $DEVICE
|
||||||
|
if test "$?" = "0";then
|
||||||
|
echo > disconnect.ok
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -20,10 +20,14 @@
|
|||||||
|
|
||||||
SERV="${SERV:-../src/ocserv}"
|
SERV="${SERV:-../src/ocserv}"
|
||||||
srcdir=${srcdir:-.}
|
srcdir=${srcdir:-.}
|
||||||
|
builddir=${builddir:-.}
|
||||||
PORT=4448
|
PORT=4448
|
||||||
|
|
||||||
. `dirname $0`/common.sh
|
. `dirname $0`/common.sh
|
||||||
|
|
||||||
|
rm -f ${builddir}/connect.ok
|
||||||
|
rm -f ${builddir}/disconnect.ok
|
||||||
|
|
||||||
echo "Testing local backend with username-password... "
|
echo "Testing local backend with username-password... "
|
||||||
|
|
||||||
launch_server -d 1 -f -c test-pass-script.config & PID=$!
|
launch_server -d 1 -f -c test-pass-script.config & PID=$!
|
||||||
@@ -33,13 +37,31 @@ echo "Connecting to obtain cookie with wrong username... "
|
|||||||
( echo "tost" | openconnect -q localhost:$PORT -u tost --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) &&
|
( echo "tost" | openconnect -q localhost:$PORT -u tost --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) &&
|
||||||
fail $PID "Received cookie when we shouldn't"
|
fail $PID "Received cookie when we shouldn't"
|
||||||
|
|
||||||
|
rm -f ${builddir}/connect.ok
|
||||||
|
rm -f ${builddir}/disconnect.ok
|
||||||
#test special characters
|
#test special characters
|
||||||
|
|
||||||
echo "Connecting to obtain cookie... "
|
echo "Connecting to obtain cookie... "
|
||||||
( echo "!@#$%^&*()<>" | openconnect -q localhost:$PORT -u special --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) ||
|
( echo "!@#$%^&*()<>" | openconnect -q localhost:$PORT -u special --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) ||
|
||||||
fail $PID "Could not receive cookie from server"
|
fail $PID "Could not receive cookie from server"
|
||||||
|
|
||||||
|
|
||||||
kill $PID
|
kill $PID
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
if ! test -f ${builddir}/connect.ok;then
|
||||||
|
echo "Connect script was not run"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! test -f ${builddir}/disconnect.ok;then
|
||||||
|
echo "Disconnect script was not run properly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f ${builddir}/connect.ok
|
||||||
|
rm -f ${builddir}/disconnect.ok
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ cookie-validity = 172800
|
|||||||
# DEVICE, IP_REAL (the real IP of the client), IP_LOCAL (the local IP
|
# DEVICE, IP_REAL (the real IP of the client), IP_LOCAL (the local IP
|
||||||
# in the P-t-P connection), IP_REMOTE (the VPN IP of the client). REASON
|
# in the P-t-P connection), IP_REMOTE (the VPN IP of the client). REASON
|
||||||
# may be "connect" or "disconnect".
|
# may be "connect" or "disconnect".
|
||||||
connect-script = /bin/true
|
connect-script = ./connect-script
|
||||||
disconnect-script = /bin/true
|
disconnect-script = ./connect-script
|
||||||
|
|
||||||
# UTMP
|
# UTMP
|
||||||
use-utmp = true
|
use-utmp = true
|
||||||
|
|||||||
Reference in New Issue
Block a user