tests: don't use ssh to obtain user information

This commit is contained in:
Nikos Mavrogiannopoulos
2015-05-20 11:34:08 +02:00
parent 7b786ed486
commit 5c146055fe
11 changed files with 43 additions and 129 deletions

View File

@@ -7,7 +7,7 @@ RUN yum install -y lz4
RUN yum install -y pam
RUN yum install -y freeradius-client
RUN yum install -y krb5-libs
RUN yum install -y pam_oath oathtool
RUN yum install -y pam_oath oathtool less
RUN systemctl enable sshd
RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/sshd_config

View File

@@ -6,7 +6,7 @@ RUN yum install -y libnl3 libtalloc
RUN yum install -y lz4
RUN yum install -y freeradius-client
RUN yum install -y freeradius
RUN yum install -y krb5-libs
RUN yum install -y krb5-libs less
RUN systemctl enable sshd
RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/sshd_config

View File

@@ -5,7 +5,7 @@ RUN yum install -y bash openssh-server nuttcp
RUN yum install -y libnl3 libtalloc
RUN yum install -y lz4
RUN yum install -y freeradius-client
RUN yum install -y freeradius
RUN yum install -y freeradius less
RUN systemctl enable sshd
RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/sshd_config

View File

@@ -5,7 +5,7 @@ RUN yum install -y bash openssh-server nuttcp
RUN yum install -y libnl3 libtalloc
RUN yum install -y freeradius-client
RUN yum install -y lz4
RUN yum install -y krb5-libs
RUN yum install -y krb5-libs less
RUN systemctl enable sshd
RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/sshd_config

View File

@@ -6,7 +6,7 @@ RUN systemctl enable sshd
RUN yum install -y libnl3 libtalloc haproxy
RUN yum install -y freeradius-client
RUN yum install -y lz4
RUN yum install -y krb5-libs
RUN yum install -y krb5-libs less
RUN sed 's/PermitRootLogin without-password/PermitRootLogin yes/g' -i /etc/ssh/sshd_config
RUN echo 'root:root' |chpasswd

View File

@@ -33,7 +33,7 @@ IMAGE_NAME=test_ocserv
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$DOCKER run -P --privileged=true -p 22 -p $PORT_OCSERV:$PORT_OCSERV/udp --tty=false -d --name $IMAGE_NAME $IMAGE
$DOCKER run -e OCCTL_PAGER=cat -P --privileged=true -p 22 --tty=false -d --name $IMAGE_NAME $IMAGE
if test $? != 0;then
echo "Cannot run docker image"
exit 1
@@ -101,25 +101,8 @@ if test $? != 0;then
stop
fi
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 "\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 users >/dev/null 2>&1
echo -e '#!'"/bin/sh\n" >echo-admin$TMP
echo -e "echo root" >>echo-admin$TMP
echo -e "\n" >>echo-admin$TMP
chmod 755 echo-admin$TMP
setsid ssh -T -F config$TMP root@192.168.1.1 occtl show users
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
$DOCKER exec -i -t $IMAGE_NAME occtl show users
$DOCKER exec -i -t $IMAGE_NAME occtl show user test >out$TMP 2>&1
grep "Username" out$TMP
if test $? != 0;then

View File

@@ -21,10 +21,6 @@
srcdir=${srcdir:-.}
SERV="${SERV:-../src/ocserv}"
PORT=10500
PORT2=10501
PORT_OCSERV=443
#this test can only be run as root
id|grep root >/dev/null 2>&1
if [ $? != 0 ];then
@@ -50,7 +46,6 @@ IMAGE=ocserv-kerberos-test
IMAGE_NAME=test_ocserv_kerberos
. ./docker-common.sh
#-p $PORT:$PORT/udp -p $PORT2:$PORT2/udp -p 22 -p $PORT_OCSERV:$PORT_OCSERV/udp
$DOCKER run -P --privileged=true --hostname=kerberos.test --add-host='kerberos.test:127.0.0.1' --tty=false -d --name test_ocserv_kerberos $IMAGE
if test $? != 0;then
echo "Cannot run docker image"

View File

@@ -30,9 +30,10 @@ fi
CONFIG="pam"
IMAGE=ocserv-pam-test
IMAGE_NAME=test_ocserv_pam
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$DOCKER run -P --privileged=true --tty=false -d --name test_ocserv_pam $IMAGE
$DOCKER run -e OCCTL_PAGER=cat -P --privileged=true --tty=false -d --name $IMAGE_NAME $IMAGE
if test $? != 0;then
echo "Cannot run docker image"
exit 1
@@ -42,7 +43,7 @@ echo "ocserv image was run"
#wait for ocserv to server
sleep 5
IP=`$DOCKER inspect test_ocserv_pam | 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
@@ -115,34 +116,18 @@ if test $? != 0;then
stop
fi
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.56.1 occtl show user testuser >out.tmp 2>&1
cat out.tmp
$DOCKER exec -i -t $IMAGE_NAME occtl show users
$DOCKER exec -i -t $IMAGE_NAME occtl show user testuser >out$TMP 2>&1
echo -e '#!'"/bin/sh\n" >echo-admin.tmp
echo -e "echo root" >>echo-admin.tmp
echo -e "\n" >>echo-admin.tmp
chmod 755 echo-admin.tmp
setsid ssh -T -F config.tmp root@192.168.56.1 occtl show user testuser >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
cat out$TMP
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.
@@ -170,7 +155,7 @@ sleep 4
#check whether /tmp/disconnect/ok was created
rm -f ./not-ok
$DOCKER cp test_ocserv_pam:/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
@@ -180,7 +165,7 @@ rm -f ./not-ok
ret=0
rm -f ./tmp-full/ok
$DOCKER cp test_ocserv_pam:/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
@@ -190,7 +175,7 @@ else
rm -rf ./tmp-full/
fi
$DOCKER stop test_ocserv_pam
$DOCKER rm test_ocserv_pam
$DOCKER stop $IMAGE_NAME
$DOCKER rm $IMAGE_NAME
exit $ret

View File

@@ -35,7 +35,7 @@ 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
$DOCKER run -e OCCTL_PAGER=cat -P --privileged=true --tty=false -d --name $IMAGE_NAME $IMAGE
if test $? != 0;then
echo "Cannot run docker image"
exit 1
@@ -45,7 +45,7 @@ echo "ocserv image was run"
#wait for ocserv to server
sleep 5
IP=`$DOCKER inspect test_ocserv_radius | 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
@@ -102,28 +102,12 @@ if test $? != 0;then
stop
fi
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.55.1 occtl show user test >out$TMP 2>&1
cat out$TMP
echo -e '#!'"/bin/sh\n" >echo-admin$TMP
echo -e "echo root" >>echo-admin$TMP
echo -e "\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
$DOCKER exec -i -t $IMAGE_NAME occtl show users
$DOCKER exec -i -t $IMAGE_NAME occtl show user test >out$TMP 2>&1
grep "Username" out$TMP
if test $? != 0;then
cat out$TMP
kill $PID
echo "could not find user information"
stop
@@ -160,7 +144,7 @@ TMPDIR=radius-$TMP
mkdir -p $TMPDIR
#check whether /tmp/disconnect/ok was created
rm -f $TMPDIR/not-ok
$DOCKER cp test_ocserv_radius:/tmp/disconnect/not-ok $TMPDIR/
$DOCKER cp $IMAGE_NAME:/tmp/disconnect/not-ok $TMPDIR/
if test -f $TMPDIR/not-ok;then
echo "There was an issue getting stats"
stop
@@ -169,18 +153,18 @@ rm -f $TMPDIR/not-ok
rm -f $TMPDIR/stats
FILE=`$DOCKER exec test_ocserv_radius ls /var/log/radius/radacct/127.0.0.1/`
echo $DOCKER exec test_ocserv_radius cat "/var/log/radius/radacct/127.0.0.1/$FILE"
$DOCKER exec test_ocserv_radius cat "/var/log/radius/radacct/127.0.0.1/$FILE"
FILE=`$DOCKER exec $IMAGE_NAME ls /var/log/radius/radacct/127.0.0.1/`
echo $DOCKER exec $IMAGE_NAME cat "/var/log/radius/radacct/127.0.0.1/$FILE"
$DOCKER exec $IMAGE_NAME cat "/var/log/radius/radacct/127.0.0.1/$FILE"
OCTETS=`$DOCKER exec test_ocserv_radius cat "/var/log/radius/radacct/127.0.0.1/$FILE"|grep Acct-Input-Octets|tail -1|sed 's/Acct-Input-Octets = //g'`
OCTETS=`$DOCKER exec $IMAGE_NAME cat "/var/log/radius/radacct/127.0.0.1/$FILE"|grep Acct-Input-Octets|tail -1|sed 's/Acct-Input-Octets = //g'`
if test -z "$OCTETS" || test "$OCTETS" = 0;then
echo "Interim update showed no data!"
stop
fi
rm -f $TMPDIR/ok
$DOCKER cp test_ocserv_radius:/tmp/disconnect/ok $TMPDIR/
$DOCKER cp $IMAGE_NAME:/tmp/disconnect/ok $TMPDIR/
if ! test -f $TMPDIR/ok;then
echo "Don't know if stats were received"
ret=77
@@ -195,9 +179,9 @@ ret=0
#wait until sec-mod has cleaned up its entries
echo "Waiting for disconnection report"
sleep 10
DISC=`$DOCKER exec test_ocserv_radius cat "/var/log/radius/radacct/127.0.0.1/$FILE"|grep "Acct-Terminate-Cause = User-Request"|tail -1`
DISC=`$DOCKER exec $IMAGE_NAME cat "/var/log/radius/radacct/127.0.0.1/$FILE"|grep "Acct-Terminate-Cause = User-Request"|tail -1`
if test -z "$DISC";then
$DOCKER exec test_ocserv_radius cat "/var/log/radius/radacct/127.0.0.1/$FILE"
$DOCKER exec $IMAGE_NAME cat "/var/log/radius/radacct/127.0.0.1/$FILE"
echo "No disconnect was detected!"
stop
fi
@@ -205,7 +189,7 @@ fi
# do the same with a certificate - test radius accounting with certificate auth
echo "Trying with certificate"
rm -f out$TMP.pid
$DOCKER exec test_ocserv_radius truncate --size=0 /var/log/radius/radacct/127.0.0.1/$FILE
$DOCKER exec $IMAGE_NAME truncate --size=0 /var/log/radius/radacct/127.0.0.1/$FILE
$OPENCONNECT $IP:$PORT_OCSERV -b --sslkey ./user-key.pem -c ./user-cert.pem --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --pid-file=out$TMP.pid
sleep 10
@@ -234,8 +218,8 @@ kill -INT $PID
sleep 10
FILE=`$DOCKER exec test_ocserv_radius ls /var/log/radius/radacct/127.0.0.1/|tail -1`
$DOCKER exec test_ocserv_radius cat "/var/log/radius/radacct/127.0.0.1/$FILE" >out$TMP
FILE=`$DOCKER exec $IMAGE_NAME ls /var/log/radius/radacct/127.0.0.1/|tail -1`
$DOCKER exec $IMAGE_NAME cat "/var/log/radius/radacct/127.0.0.1/$FILE" >out$TMP
cat out$TMP
OCTETS=`cat out$TMP|grep Acct-Input-Octets|tail -1|sed 's/Acct-Input-Octets = //g'`
if test -z "$OCTETS" || test "$OCTETS" = 0;then
@@ -264,8 +248,8 @@ if test -n "$DISC";then
stop
fi
$DOCKER stop test_ocserv_radius
$DOCKER rm test_ocserv_radius
$DOCKER stop $IMAGE_NAME
$DOCKER rm $IMAGE_NAME
rm -f out$TMP

View File

@@ -33,7 +33,7 @@ IMAGE_NAME=test_ocserv_radius_config
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$DOCKER run -P --privileged=true -p 22 -p $PORT_OCSERV:$PORT_OCSERV/udp --tty=false -d --name $IMAGE_NAME $IMAGE
$DOCKER run -e OCCTL_PAGER=cat -P --privileged=true --tty=false -d --name $IMAGE_NAME $IMAGE
if test $? != 0;then
echo "Cannot run docker image"
exit 1
@@ -73,21 +73,8 @@ if test $? != 0;then
fi
#check whether the routes have been applied
rm -f known-hosts$TMP
echo -e '#!'"/bin/sh\n" >echo-admin$TMP
echo -e "echo yes" >>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.66.1 occtl show users
echo -e '#!'"/bin/sh\n" >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.66.1 occtl show user testtime >out$TMP 2>&1
cat out$TMP
$DOCKER exec -i -t $IMAGE_NAME occtl show users
$DOCKER exec -i -t $IMAGE_NAME occtl show user testtime >out$TMP 2>&1
grep '192.168.155.0/255.255.255.0' out$TMP
if test $? != 0;then
@@ -98,8 +85,6 @@ if test $? != 0;then
fi
rm -f out$TMP
rm -f known-hosts$TMP
rm -f echo-admin$TMP
echo "Waiting for accounting report"

View File

@@ -33,7 +33,7 @@ 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
$DOCKER run -e OCCTL_PAGER=cat -P --privileged=true --tty=false -d --name test_unix $IMAGE
if test $? != 0;then
echo "Cannot run docker image"
exit 1
@@ -77,25 +77,7 @@ if test $? != 0;then
stop
fi
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.99.1 occtl show user test >out$TMP 2>&1
cat out$TMP
echo -e '#!'"/bin/sh\n" >echo-admin$TMP
echo -e "echo root" >>echo-admin$TMP
echo -e "\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
$DOCKER exec -i -t $IMAGE_NAME occtl show user test >out$TMP 2>&1
grep "Username" out$TMP
if test $? != 0;then