From 419fd1e63cde6566bd7118f81b4e8aa0d39275b3 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Tue, 19 May 2015 19:00:53 +0200 Subject: [PATCH] tests: avoid using double newlines and other updates in full-test --- tests/docker-ocserv/Dockerfile-debian-tcp | 8 ++----- tests/docker-ocserv/Dockerfile-fedora-tcp | 8 ++----- tests/docker-ocserv/ocserv.conf | 6 ++++-- tests/full-test | 26 +++++++++++------------ tests/radius-test | 6 +++--- tests/radius-test-config | 2 +- tests/unix-test | 2 +- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/tests/docker-ocserv/Dockerfile-debian-tcp b/tests/docker-ocserv/Dockerfile-debian-tcp index 66cc9497..0c146c31 100644 --- a/tests/docker-ocserv/Dockerfile-debian-tcp +++ b/tests/docker-ocserv/Dockerfile-debian-tcp @@ -15,12 +15,8 @@ RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/s RUN echo 'root:root' |chpasswd RUN useradd -m -d /home/admin -s /bin/bash admin RUN echo 'admin:admin' |chpasswd -EXPOSE 5000 -EXPOSE 5000/udp -EXPOSE 5001 -EXPOSE 5001/udp -EXPOSE 5551 -EXPOSE 5551/udp +EXPOSE 443 +EXPOSE 443/udp EXPOSE 22 RUN mkdir /etc/ocserv diff --git a/tests/docker-ocserv/Dockerfile-fedora-tcp b/tests/docker-ocserv/Dockerfile-fedora-tcp index 7541541d..3c04acce 100644 --- a/tests/docker-ocserv/Dockerfile-fedora-tcp +++ b/tests/docker-ocserv/Dockerfile-fedora-tcp @@ -12,12 +12,8 @@ RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/s RUN echo 'root:root' |chpasswd RUN useradd -m -d /home/admin -s /bin/bash admin RUN echo 'admin:admin' |chpasswd -EXPOSE 5000 -EXPOSE 5000/udp -EXPOSE 5001 -EXPOSE 5001/udp -EXPOSE 5551 -EXPOSE 5551/udp +EXPOSE 443 +EXPOSE 443/udp EXPOSE 22 RUN mkdir /etc/ocserv diff --git a/tests/docker-ocserv/ocserv.conf b/tests/docker-ocserv/ocserv.conf index 2f62d2fe..76b0ebb6 100644 --- a/tests/docker-ocserv/ocserv.conf +++ b/tests/docker-ocserv/ocserv.conf @@ -40,8 +40,8 @@ max-clients = 16 max-same-clients = 2 # TCP and UDP port number -tcp-port = 5551 -udp-port = 5551 +tcp-port = 443 +udp-port = 443 # Keepalive in seconds keepalive = 32400 @@ -131,6 +131,8 @@ auth-timeout = 40 # a failed authentication attempt. #min-reauth-time = 2 +#max-ban-score = 50 + # Cookie validity time (in seconds) # Once a client is authenticated he's provided a cookie with # which he can reconnect. This option sets the maximum lifetime diff --git a/tests/full-test b/tests/full-test index 9bb9de59..6da4657f 100755 --- a/tests/full-test +++ b/tests/full-test @@ -26,14 +26,14 @@ if [ $? != 0 ];then exit 77 fi -PORT_OCSERV=5551 +PORT_OCSERV=443 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 +$DOCKER run -P --privileged=true -p 22 -p $PORT_OCSERV:$PORT_OCSERV/udp --tty=false -d --name $IMAGE_NAME $IMAGE if test $? != 0;then echo "Cannot run docker image" exit 1 @@ -43,7 +43,7 @@ echo "ocserv image was run" #wait for ocserv to server sleep 5 -IP=`$DOCKER inspect test_ocserv | grep IPAddress | cut -d '"' -f 4` +IP=`$DOCKER inspect $IMAGE_NAME | grep IPAddress | cut -d '"' -f 4` if test -z "$IP";then echo "Detected IP is null!" stop @@ -54,21 +54,23 @@ if test ! -z "$QUIT_ON_INIT";then exit 0 fi -echo -e "testuser\n" >pass-full$TMP +echo -e "testuser" >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 -echo -e "test\n" >pass-full$TMP +echo -e "test" >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 -echo -e "test\n" >pass-full$TMP +echo "" +echo "Connecting with correct username" +echo -e "test" >pass-full$TMP $OPENCONNECT $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-full$TMP & PID=$! @@ -103,12 +105,10 @@ rm -f known-hosts$TMP echo "UserKnownHostsFile ./known-hosts$TMP" >config$TMP echo -e '#!'"/bin/sh\n" >echo-admin$TMP echo -e "echo yes" >>echo-admin$TMP -echo -e "echo root" >>echo-admin$TMP echo -e "\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 +setsid ssh -T -F config$TMP root@192.168.1.1 occtl show users >/dev/null 2>&1 echo -e '#!'"/bin/sh\n" >echo-admin$TMP echo -e "echo root" >>echo-admin$TMP @@ -157,7 +157,7 @@ sleep 4 #check whether /tmp/disconnect/ok was created rm -f ./not-ok -$DOCKER cp test_ocserv:/tmp/disconnect/not-ok ./ +$DOCKER cp $IMAGE_NAME:/tmp/disconnect/not-ok ./ if test -f ./not-ok;then echo "There was an issue getting stats" stop @@ -167,7 +167,7 @@ rm -f ./not-ok ret=0 rm -f ./tmp-full/ok -$DOCKER cp test_ocserv:/tmp/disconnect/ok ./tmp-full/ +$DOCKER cp $IMAGE_NAME:/tmp/disconnect/ok ./tmp-full/ if ! test -f ./tmp-full/ok;then echo "Don't know if stats were received" ret=77 @@ -177,7 +177,7 @@ else rm -rf ./tmp-full/ fi -$DOCKER stop test_ocserv -$DOCKER rm test_ocserv +$DOCKER stop $IMAGE_NAME +$DOCKER rm $IMAGE_NAME exit $ret diff --git a/tests/radius-test b/tests/radius-test index e738d56f..b60a7286 100755 --- a/tests/radius-test +++ b/tests/radius-test @@ -56,14 +56,14 @@ if test ! -z "$QUIT_ON_INIT";then exit 0 fi -echo -e "testuser\n" >pass-radius$TMP +echo -e "testuser" >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 -echo -e "test\n" >pass-radius$TMP +echo -e "test" >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!" @@ -71,7 +71,7 @@ if test $? = 0;then fi echo "Trying with correct password" -echo -e "test\n" >pass-radius$TMP +echo -e "test" >pass-radius$TMP $OPENCONNECT $IP:$PORT_OCSERV -u test --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-radius$TMP & PID=$! diff --git a/tests/radius-test-config b/tests/radius-test-config index 0d54ce3d..b30cd73c 100755 --- a/tests/radius-test-config +++ b/tests/radius-test-config @@ -55,7 +55,7 @@ if test ! -z "$QUIT_ON_INIT";then fi echo "Trying with correct password" -printf "test\n" >pass-radius$TMP +echo "test" >pass-radius$TMP $OPENCONNECT $IP:$PORT_OCSERV -u testtime --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-radius$TMP & PID=$! diff --git a/tests/unix-test b/tests/unix-test index 4404660a..9e6e9b55 100755 --- a/tests/unix-test +++ b/tests/unix-test @@ -53,7 +53,7 @@ if test ! -z "$QUIT_ON_INIT";then exit 0 fi -echo -e "test\ntest\n" >pass$TMP +echo -e "test\ntest" >pass$TMP $OPENCONNECT $IP:6551 -u test --passwd-on-stdin --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass$TMP & PID=$!