1#!/bin/sh
2#
3# Copyright (c) 2006 - 2007 Kungliga Tekniska Högskolan
4# (Royal Institute of Technology, Stockholm, Sweden). 
5# All rights reserved. 
6#
7# Portions Copyright (c) 2009 - 2010 Apple Inc. All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without 
10# modification, are permitted provided that the following conditions 
11# are met: 
12#
13# 1. Redistributions of source code must retain the above copyright 
14#    notice, this list of conditions and the following disclaimer. 
15#
16# 2. Redistributions in binary form must reproduce the above copyright 
17#    notice, this list of conditions and the following disclaimer in the 
18#    documentation and/or other materials provided with the distribution. 
19#
20# 3. Neither the name of the Institute nor the names of its contributors 
21#    may be used to endorse or promote products derived from this software 
22#    without specific prior written permission. 
23#
24# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
25# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
26# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
27# ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
28# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
29# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
30# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
31# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
32# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
33# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
34# SUCH DAMAGE. 
35
36env_setup="@env_setup@"
37confdir="@confdir@"
38testdir="@testdir@"
39
40mkdir -p $testdir 2> /dev/null
41
42u=heimleo
43r=LEONIDAS.APPLE.COM
44ntdomain=LEONIDAS
45pw=foo
46
47. ${env_setup}
48
49KRB5_CONFIG="${1-${confdir}/krb5.conf}"
50export KRB5_CONFIG
51
52logfile=${testdir}/messages.log
53cache="FILE:${testdir}/cache.krb5"
54
55testfailed="echo test failed; cat ${logfile}; exit 1"
56
57kinit="${kinit} -c $cache"
58klist="${klist} -c $cache"
59kgetcred="${kgetcred} -c $cache"
60kdestroy="${kdestroy} -c $cache"
61
62rm -f ${testdir}/out-*
63
64> ${logfile}
65
66echo foo > ${testdir}/foopassword
67
68for a in 1 2 3 4 5 6 7 8 9 10 ; do
69    echo "Getting client initial tickets ${a}"; > ${logfile}
70    ${kinit} --password-file=${testdir}/foopassword ${u}@${r}:localhost || \
71	{ ec=1 ; eval "${testfailed}"; }
72done
73echo "Getting tickets"; > ${logfile}
74${kgetcred} host/${r}@${r} || { ec=1 ; eval "${testfailed}"; }
75echo "Listing tickets"; > ${logfile}
76${klist} > /dev/null || { ec=1 ; eval "${testfailed}"; }
77${kdestroy}
78
79digestservice=com.apple.Kerberos.digest-service
80ds=/System/Library/LaunchDaemons/$digestservice.plist
81
82launchctl unload $ds
83killall -9 digest-service 2>/dev/null
84launchctl load $ds
85
86${test_gssntlm} --user=$u --domain=${ntdomain} --password=${pw}
87
88trap "" EXIT
89
90exit $ec
91