Test for iprop.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21753 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-07-31 21:13:17 +00:00
parent 0338917c9b
commit 04a0453e5e

179
tests/kdc/check-iprop.in Normal file
View File

@@ -0,0 +1,179 @@
#!/bin/sh
#
# Copyright (c) 2006 - 2007 Kungliga Tekniska H<>gskolan
# (Royal Institute of Technology, Stockholm, Sweden).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Institute nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Id$
#
srcdir="@srcdir@"
objdir="@objdir@"
EGREP="@EGREP@"
# If there is no useful db support compile in, disable test
../db/have-db || exit 77
R=TEST.H5L.SE
port=@port@
cache="FILE:${objdir}/cache.krb5"
keytabfile=${objdir}/iprop.keytab
keytab="FILE:${keytabfile}"
kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -r $R"
ipropdslave="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-slave"
ipropdmaster="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-master"
kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
KRB5_CONFIG="${objdir}/krb5.conf"
export KRB5_CONFIG
rm -f ${keytabfile}
rm -f current-db*
rm -f current*.log
rm -f out-*
rm -f mkey.file*
rm -f messages.log
echo Creating database
${kadmin} -l \
init \
--realm-max-ticket-life=1day \
--realm-max-renewable-life=1month \
${R} || exit 1
${kadmin} -l add -p foo --use-defaults foo/admin@${R} || exit 1
${kadmin} -l add --random-key --use-defaults iprop/localhost@${R} || exit 1
${kadmin} -l ext -k ${keytab} iprop/localhost@${R} || exit 1
${kadmin} -l add --random-key --use-defaults iprop/slave@${R} || exit 1
${kadmin} -l ext -k ${keytab} iprop/slave@${R} || exit 1
echo foo > ${objdir}/foopassword
# -- foo
ipds=
ipdm=
kdcpid=
trap "kill \${ipdm} \${ipds} \${kdcpid}; echo killing ipropd slave + master; exit 1;" EXIT
echo Starting kdc
${kdc} &
kdcpid=$!
sh ${srcdir}/wait-kdc.sh
if [ "$?" != 0 ] ; then
kill ${kdcpid}
exit 1
fi
echo "starting master"
${ipropdmaster} --hostname=localhost -k ${keytab} &
ipdm=$!
sleep 2
echo "starting slave"
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${ipropdslave} --hostname=slave -k ${keytab} localhost &
ipds=$!
sleep 2
echo "checking slave is up"
${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
echo "Add host"
${kadmin} -l add --random-key --use-defaults host/foo@${R} || exit 1
sleep 2
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${kadmin} -l get host/foo@${R} > /dev/null || exit 1
echo "Rename host"
${kadmin} -l rename host/foo@${R} host/bar@${R} || exit 1
sleep 2
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null && exit 1
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${kadmin} -l get host/bar@${R} > /dev/null || exit 1
echo "Delete host"
${kadmin} -l delete host/bar@${R} || exit 1
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${kadmin} -l get host/bar@${R} > /dev/null 2>/dev/null && exit 1
echo "kill slave"
> iprop-stats
kill ${ipds}
sleep 2
${EGREP} 'iprop/slave@TEST.H5L.SE.*Down' iprop-stats >/dev/null || exit 1
echo "starting slave again"
> iprop-stats
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${ipropdslave} --hostname=slave -k ${keytab} localhost &
ipds=$!
sleep 2
echo "checking slave is up again"
${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
echo "checking for replay problems"
${EGREP} 'Entry already exists in database' messages.log && exit 1
echo "kill slave and remove log and database"
kill ${ipds}
sleep 2
rm current.slave.log current-db.slave*
> iprop-stats
> messages.log
KRB5_CONFIG="${objdir}/krb5-slave.conf" \
${ipropdslave} --hostname=slave -k ${keytab} localhost &
ipds=$!
sleep 2
echo "checking slave is up again"
${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
echo "checking for replay problems"
${EGREP} 'Entry already exists in database' messages.log && exit 1
trap "" EXIT
kill ${ipdm} ${ipds} ${kdcpid}
sleep 2
${EGREP} "^master down at " iprop-stats > /dev/null || exit 1
echo "compare logs"
cmp current.slave.log current.log || exit 1
exit $ec