From 6647ddcbd307228160b1bc15d504abaff7bc118c Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Tue, 24 Feb 2015 16:22:32 +0100 Subject: [PATCH] tests: use unique temp files --- tests/full-test | 56 ++++++++++++++++++++++++----------------------- tests/radius-test | 55 +++++++++++++++++++++++----------------------- tests/unix-test | 47 ++++++++++++++++++++------------------- 3 files changed, 81 insertions(+), 77 deletions(-) diff --git a/tests/full-test b/tests/full-test index 5a597a27..9c3db9f7 100755 --- a/tests/full-test +++ b/tests/full-test @@ -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. diff --git a/tests/radius-test b/tests/radius-test index f33f2a2b..3323d2ce 100755 --- a/tests/radius-test +++ b/tests/radius-test @@ -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. diff --git a/tests/unix-test b/tests/unix-test index 70e1ccfc..7b821f50 100755 --- a/tests/unix-test +++ b/tests/unix-test @@ -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.