tests: use unique temp files

This commit is contained in:
Nikos Mavrogiannopoulos
2015-02-24 16:22:32 +01:00
parent cb52dd943e
commit 6647ddcbd3
3 changed files with 81 additions and 77 deletions

View File

@@ -29,6 +29,7 @@ fi
CONFIG="tcp"
IMAGE=ocserv-test1
IMAGE_NAME=test_ocserv
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$DOCKER run -P --privileged=true -p 5000:5000/udp -p 5001:5001/udp -p 22 -p 5551:5551/udp --tty=false -d --name test_ocserv $IMAGE
@@ -52,25 +53,25 @@ if test ! -z "$QUIT_ON_INIT";then
exit 0
fi
printf "test\ntestuser\n" >pass-full.tmp
openconnect $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-full.tmp
printf "test\ntestuser\n" >pass-full$TMP
openconnect $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-full$TMP
if test $? = 0;then
echo "Authentication with wrong password succeeded!"
stop
fi
printf "test\ntest\n" >pass-full.tmp
openconnect $IP:$PORT_OCSERV -u testuser --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-full.tmp
printf "test\ntest\n" >pass-full$TMP
openconnect $IP:$PORT_OCSERV -u testuser --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-full$TMP
if test $? = 0;then
echo "Authentication with wrong username succeeded!"
stop
fi
printf "test\ntest\n" >pass-full.tmp
openconnect $IP:5551 -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-full.tmp &
printf "test\ntest\n" >pass-full$TMP
openconnect $IP:5551 -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-full$TMP &
PID=$!
rm -f pass-full.tmp
rm -f pass-full$TMP
#wait for openconnect
sleep 5
@@ -97,34 +98,35 @@ if test $? != 0;then
stop
fi
echo "UserKnownHostsFile ./known-hosts.tmp" >config.tmp
printf "#\!/bin/sh\n" >echo-admin.tmp
printf "echo yes" >>echo-admin.tmp
printf "echo root" >>echo-admin.tmp
printf "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
export SSH_ASKPASS="./echo-admin.tmp"
setsid ssh -T -F config.tmp root@192.168.1.1 occtl show user test >out.tmp 2>&1
cat out.tmp
echo "UserKnownHostsFile ./known-hosts$TMP" >config$TMP
printf "#\!/bin/sh\n" >echo-admin$TMP
printf "echo yes" >>echo-admin$TMP
printf "echo root" >>echo-admin$TMP
printf "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
export SSH_ASKPASS="./echo-admin$TMP"
setsid ssh -T -F config$TMP root@192.168.1.1 occtl show user test >out$TMP 2>&1
cat out$TMP
printf "#\!/bin/sh\n" >echo-admin.tmp
printf "echo root" >>echo-admin.tmp
printf "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
setsid ssh -T -F config.tmp root@192.168.1.1 occtl show user test >out.tmp 2>&1
cat out.tmp
rm -f echo-admin.tmp
rm -f config.tmp
rm -f known-hosts.tmp
printf "#\!/bin/sh\n" >echo-admin$TMP
printf "echo root" >>echo-admin$TMP
printf "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
setsid ssh -T -F config$TMP root@192.168.1.1 occtl show user test >out$TMP 2>&1
cat out$TMP
rm -f echo-admin$TMP
rm -f config$TMP
rm -f known-hosts$TMP
grep "Username" out.tmp
grep "Username" out$TMP
if test $? != 0;then
kill $PID
cat out$TMP
echo "could not find user information"
stop
fi
rm -f out.tmp
rm -f out$TMP
# There is an issue in nuttcp that makes it crash under docker if
# /proc/sys/net/ipv4/tcp_adv_win_scale does not exist.

View File

@@ -32,6 +32,7 @@ fi
CONFIG="radius"
IMAGE=ocserv-radius-test
IMAGE_NAME=test_ocserv_radius
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$DOCKER run -P --privileged=true -p $PORT:$PORT/udp -p $PORT2:$PORT2/udp -p 22 -p $PORT_OCSERV:$PORT_OCSERV/udp --tty=false -d --name test_ocserv_radius $IMAGE
@@ -55,25 +56,25 @@ if test ! -z "$QUIT_ON_INIT";then
exit 0
fi
printf "testuser\n" >pass-radius.tmp
openconnect $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-radius.tmp
printf "testuser\n" >pass-radius$TMP
openconnect $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-radius$TMP
if test $? = 0;then
echo "Authentication with wrong password succeeded!"
stop
fi
printf "test\ntest\n" >pass-radius.tmp
openconnect $IP:$PORT_OCSERV -u testuser --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-radius.tmp
printf "test\ntest\n" >pass-radius$TMP
openconnect $IP:$PORT_OCSERV -u testuser --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly < pass-radius$TMP
if test $? = 0;then
echo "Authentication with wrong username succeeded!"
stop
fi
printf "test\ntest\n" >pass-radius.tmp
openconnect $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-radius.tmp &
printf "test\ntest\n" >pass-radius$TMP
openconnect $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-radius$TMP &
PID=$!
rm -f pass-radius.tmp
rm -f pass-radius$TMP
#wait for openconnect
sleep 5
@@ -100,34 +101,34 @@ if test $? != 0;then
stop
fi
echo "UserKnownHostsFile ./known-hosts.tmp" >config.tmp
printf "#\!/bin/sh\n" >echo-admin.tmp
printf "echo yes" >>echo-admin.tmp
printf "echo root" >>echo-admin.tmp
printf "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
export SSH_ASKPASS="./echo-admin.tmp"
setsid ssh -T -F config.tmp root@192.168.55.1 occtl show user test >out.tmp 2>&1
cat out.tmp
echo "UserKnownHostsFile ./known-hosts$TMP" >config$TMP
printf "#\!/bin/sh\n" >echo-admin$TMP
printf "echo yes" >>echo-admin$TMP
printf "echo root" >>echo-admin$TMP
printf "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
export SSH_ASKPASS="./echo-admin$TMP"
setsid ssh -T -F config$TMP root@192.168.55.1 occtl show user test >out$TMP 2>&1
cat out$TMP
printf "#\!/bin/sh\n" >echo-admin.tmp
printf "echo root" >>echo-admin.tmp
printf "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
setsid ssh -T -F config.tmp root@192.168.55.1 occtl show user test >out.tmp 2>&1
cat out.tmp
rm -f echo-admin.tmp
rm -f config.tmp
rm -f known-hosts.tmp
printf "#\!/bin/sh\n" >echo-admin$TMP
printf "echo root" >>echo-admin$TMP
printf "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
setsid ssh -T -F config$TMP root@192.168.55.1 occtl show user test >out$TMP 2>&1
cat out$TMP
rm -f echo-admin$TMP
rm -f config$TMP
rm -f known-hosts$TMP
grep "Username" out.tmp
grep "Username" out$TMP
if test $? != 0;then
kill $PID
echo "could not find user information"
stop
fi
rm -f out.tmp
rm -f out$TMP
# There is an issue in nuttcp that makes it crash under docker if
# /proc/sys/net/ipv4/tcp_adv_win_scale does not exist.

View File

@@ -30,6 +30,7 @@ UNIX=1
CONFIG="unix"
IMAGE=ocserv-test2
IMAGE_NAME=test_unix
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$DOCKER run -P --privileged=true -p 6000:6000/udp -p 6001:6001/udp -p 22 -p 6551:6551/udp --tty=false -d --name test_unix $IMAGE
@@ -52,11 +53,11 @@ if test ! -z "$QUIT_ON_INIT";then
exit 0
fi
printf "test\ntest\n" >pass.tmp
openconnect $IP:6551 -u test --passwd-on-stdin --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass.tmp &
printf "test\ntest\n" >pass$TMP
openconnect $IP:6551 -u test --passwd-on-stdin --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass$TMP &
PID=$!
rm -f pass.tmp
rm -f pass$TMP
#wait for openconnect
sleep 5
@@ -76,34 +77,34 @@ if test $? != 0;then
stop
fi
echo "UserKnownHostsFile ./known-hosts.tmp" >config.tmp
printf "#\!/bin/sh\n" >echo-admin.tmp
printf "echo yes" >>echo-admin.tmp
printf "echo root" >>echo-admin.tmp
printf "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
export SSH_ASKPASS="./echo-admin.tmp"
setsid ssh -T -F config.tmp root@192.168.99.1 occtl show user test >out.tmp 2>&1
cat out.tmp
echo "UserKnownHostsFile ./known-hosts$TMP" >config$TMP
printf "#\!/bin/sh\n" >echo-admin$TMP
printf "echo yes" >>echo-admin$TMP
printf "echo root" >>echo-admin$TMP
printf "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
export SSH_ASKPASS="./echo-admin$TMP"
setsid ssh -T -F config$TMP root@192.168.99.1 occtl show user test >out$TMP 2>&1
cat out$TMP
printf "#\!/bin/sh\n" >echo-admin.tmp
printf "echo root" >>echo-admin.tmp
printf "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
setsid ssh -T -F config.tmp root@192.168.99.1 occtl show user test >out.tmp 2>&1
cat out.tmp
rm -f echo-admin.tmp
rm -f config.tmp
rm -f known-hosts.tmp
printf "#\!/bin/sh\n" >echo-admin$TMP
printf "echo root" >>echo-admin$TMP
printf "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
setsid ssh -T -F config$TMP root@192.168.99.1 occtl show user test >out$TMP 2>&1
cat out$TMP
rm -f echo-admin$TMP
rm -f config$TMP
rm -f known-hosts$TMP
grep "Username" out.tmp
grep "Username" out$TMP
if test $? != 0;then
kill $PID
echo "could not find user information"
stop
fi
rm -f out.tmp
rm -f out$TMP
# There is an issue in nuttcp that makes it crash under docker if
# /proc/sys/net/ipv4/tcp_adv_win_scale does not exist.