From 5dcd51ca0f9bb4baedbeff19cc12b2e28c7991c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 12 Oct 2006 11:42:15 +0000 Subject: [PATCH] Check if the gss context tester test_context works ok. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18425 ec53bebd-3082-4978-b11e-865c3cabbd6b --- tests/gss/Makefile.am | 10 +++- tests/gss/check-context.in | 101 +++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 tests/gss/check-context.in diff --git a/tests/gss/Makefile.am b/tests/gss/Makefile.am index 79c817f4f..2373e7792 100644 --- a/tests/gss/Makefile.am +++ b/tests/gss/Makefile.am @@ -4,7 +4,7 @@ include $(top_srcdir)/Makefile.am.common noinst_DATA = krb5.conf -SCRIPT_TESTS = check-gss check-gssmask +SCRIPT_TESTS = check-gss check-gssmask check-context TESTS = $(SCRIPT_TESTS) @@ -23,6 +23,11 @@ check-gssmask: check-gssmask.in Makefile chmod +x check-gssmask.tmp mv check-gssmask.tmp check-gssmask +check-context: check-context.in Makefile + $(do_subst) < $(srcdir)/check-context.in > check-context.tmp + chmod +x check-context.tmp + mv check-context.tmp check-context + krb5.conf: krb5.conf.in Makefile $(do_subst) < $(srcdir)/krb5.conf.in > krb5.conf.tmp mv krb5.conf.tmp krb5.conf @@ -34,4 +39,5 @@ CLEANFILES= \ current-db* \ *.log \ check-gss.tmp \ - check-gssmask.tmp + check-gssmask.tmp \ + check-context.tmp diff --git a/tests/gss/check-context.in b/tests/gss/check-context.in new file mode 100644 index 000000000..a0a7eb750 --- /dev/null +++ b/tests/gss/check-context.in @@ -0,0 +1,101 @@ +#!/bin/sh +# +# Copyright (c) 2006 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@" + +R=EXAMPLE.ORG + +port=8888 + +keytabfile=${objdir}/server.keytab +keytab="FILE:${keytabfile}" +cache="FILE:krb5ccfile" + +kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog" +kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R" +kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port" + +context="env KRB5CCNAME=${cache} ${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context" + +KRB5_CONFIG="${objdir}/krb5.conf" +export KRB5_CONFIG + +rm -f ${keytabfile} +rm -f current-db* +rm -f out-* +rm -f mkey.file* + +echo Creating database +${kadmin} \ + init \ + --realm-max-ticket-life=1day \ + --realm-max-renewable-life=1month \ + ${R} || exit 1 + +${kadmin} add -p p1 --use-defaults host/lucid.example.org@${R} || exit 1 +${kadmin} ext -k ${keytab} host/lucid.example.org@${R} || exit 1 + +${kadmin} add -p u1 --use-defaults user1@${R} || exit 1 + +echo "Doing database check" +${kadmin} check ${R} || exit 1 + +echo u1 > ${objdir}/foopassword + +echo Starting kdc +${kdc} & +kdcpid=$! + +sh ${srcdir}/../kdc/wait-kdc.sh +if [ "$?" != 0 ] ; then + kill ${kdcpid} + exit 1 +fi + +exitcode=0 + +echo "Getting client initial tickets" +${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode=1 + +${context} host/lucid.example.org@${R} || exitcode=1 + +echo "killing kdc (${kdcpid})" +kill ${kdcpid} 2> /dev/null + +exit $exitcode + +