mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 16:57:00 +08:00
tests: use common function to check for file existence
This addresses issue with "docker cp" in some systems.
This commit is contained in:
@@ -38,6 +38,56 @@ if test -z $FEDORA && test -z $DEBIAN;then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
check_for_file() {
|
||||
FILENAME=$1
|
||||
|
||||
rm -f out$TMP
|
||||
$DOCKER exec -i -t $IMAGE_NAME ls $FILENAME >out$TMP
|
||||
grep "$FILENAME" out$TMP|grep -v "cannot access"
|
||||
if test $? != 0;then
|
||||
echo "could not find $FILENAME"
|
||||
return 1
|
||||
else
|
||||
rm -f out$TMP
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
retrieve_user_info() {
|
||||
USERNAME=$1
|
||||
MATCH=$2
|
||||
counter=0
|
||||
ret=1
|
||||
|
||||
while [ $counter -lt 4 ]
|
||||
do
|
||||
$DOCKER exec -i -t $IMAGE_NAME occtl show user $USERNAME >out$TMP 2>&1
|
||||
if test -z "$MATCH";then
|
||||
grep "Username" out$TMP
|
||||
else
|
||||
grep "$MATCH" out$TMP
|
||||
fi
|
||||
ret=$?
|
||||
if test $ret == 0;then
|
||||
break
|
||||
fi
|
||||
counter=`expr $counter + 1`
|
||||
sleep 2
|
||||
done
|
||||
if test $ret != 0;then
|
||||
kill $PID
|
||||
cat out$TMP
|
||||
echo "could not find user information"
|
||||
stop
|
||||
else
|
||||
rm -f out$TMP
|
||||
fi
|
||||
}
|
||||
|
||||
retrieve_route_info() {
|
||||
retrieve_user_info $1 $2
|
||||
}
|
||||
|
||||
stop() {
|
||||
$DOCKER stop $IMAGE_NAME
|
||||
$DOCKER rm $IMAGE_NAME
|
||||
|
||||
Reference in New Issue
Block a user