1#!/bin/sh 2# 3# Copyright (C) 2014 Red Hat 4# 5# This file is part of ocserv. 6# 7# ocserv is free software; you can redistribute it and/or modify it 8# under the terms of the GNU General Public License as published by the 9# Free Software Foundation; either version 2 of the License, or (at 10# your option) any later version. 11# 12# ocserv is distributed in the hope that it will be useful, but 13# WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with GnuTLS; if not, write to the Free Software Foundation, 19# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 21SERV="${SERV:-../src/ocserv}" 22srcdir=${srcdir:-.} 23TMPFILE=${srcdir}/outfile.$$ 24 25. `dirname $0`/common.sh 26 27eval "${GETPORT}" 28 29connect() 30{ 31opts=$1 32pass=$2 33COOKIE='' 34eval `echo "$pass" | $OPENCONNECT -q localhost:$PORT $opts --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --authenticate` 35if [ -z "$COOKIE" ];then 36 return 1 37fi 38 39rm -f $TMPFILE 40echo "$pass" | $OPENCONNECT -q localhost:$PORT $opts -C "$COOKIE" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true --verbose --pid-file ${srcdir}/pidx >$TMPFILE 2>&1 & 41CPID=$! 42 43sleep 3 44grep "Established DTLS" $TMPFILE >/dev/null 2>&1 45if test $? != 0;then 46 cat $TMPFILE 47 rm -f $TMPFILE 48 return 1 49fi 50 51rm -f $TMPFILE 52kill $CPID 53return 0 54} 55 56echo "Testing local backend with username-password and explicit IP addresses... " 57 58update_config test-explicit-ip.config 59launch_server -d 1 -f -c "${CONFIG}" & PID=$! 60wait_server $PID 61 62echo -n "Connecting with an illegal address assigned... " 63connect "-u test2" "test2" 64if test $? = 0;then 65 fail $PID "Connected using an illegal address!" 66fi 67echo ok 68 69echo -n "Connecting with a proper address... " 70connect "-u test" "test" 71if test $? != 0;then 72 fail $PID "Failed to connect!" 73fi 74echo ok 75 76echo -n "Connecting with an illegal IPv6 address assigned... " 77connect "-u test4" "test4" 78if test $? = 0;then 79 fail $PID "Connected using an illegal address!" 80fi 81echo ok 82 83echo -n "Connecting with a proper IPv6 address... " 84connect "-u test3" "test3" 85if test $? != 0;then 86 fail $PID "Failed to connect!" 87fi 88echo ok 89 90kill $PID 91wait 92 93exit 0 94