Files
ocserv/tests/radius-group-test
Nikos Mavrogiannopoulos 071a37aaa4 tests: Added test for radius group receiving
This tests the receiving of groups using "Class" radius attribute
in the format "OU=group1;group2".
2016-04-01 15:39:38 +02:00

93 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright (C) 2014-2016 Red Hat
# Copyright (C) 2016 Nikos Mavrogiannopoulos
#
# This file is part of ocserv.
#
# ocserv is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# ocserv is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ocserv; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
srcdir=${srcdir:-.}
PORT_OCSERV=10522
#this test can only be run as root
id|grep root >/dev/null 2>&1
if [ $? != 0 ];then
exit 77
fi
CONFIG="radius-group"
IMAGE=ocserv-radius-group-test
IMAGE_NAME=test_ocserv_radius_group
TMP=$IMAGE_NAME.tmp
. ./docker-common.sh
$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
fi
echo "ocserv image was run"
#wait for ocserv to server
sleep 5
get_ip
if test -z "$IP";then
echo "Detected IP is null!"
stop
fi
echo "Detected IP: $IP"
if test ! -z "$QUIT_ON_INIT";then
exit 0
fi
echo "Trying with correct password"
$ECHO_E "test-class" >pass-radius$TMP
$OPENCONNECT $IP:$PORT_OCSERV -u test-class --authgroup group2 --passwd-on-stdin -v --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 < pass-radius$TMP &
PID=$!
#wait for openconnect
sleep 5
rm -f pass-radius$TMP
# The client IP depends on the username so it shouldn't change.
ping -w 5 192.168.35.1
if test $? != 0;then
kill -INT $PID
echo "Cannot ping ocserv"
stop
fi
ping -w 5 192.168.35.1 -s 1500
if test $? != 0;then
kill -INT $PID
echo "Cannot ping ocserv"
stop
fi
retrieve_user_info test-class group2
kill -INT $PID
$DOCKER stop $IMAGE_NAME
$DOCKER rm $IMAGE_NAME
rm -f out$TMP
exit $ret