]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - crypto/heimdal/tests/gss/check-context.in
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / crypto / heimdal / tests / gss / check-context.in
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 - 2008 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden). 
5 # All rights reserved. 
6 #
7 # Redistribution and use in source and binary forms, with or without 
8 # modification, are permitted provided that the following conditions 
9 # are met: 
10 #
11 # 1. Redistributions of source code must retain the above copyright 
12 #    notice, this list of conditions and the following disclaimer. 
13 #
14 # 2. Redistributions in binary form must reproduce the above copyright 
15 #    notice, this list of conditions and the following disclaimer in the 
16 #    documentation and/or other materials provided with the distribution. 
17 #
18 # 3. Neither the name of the Institute nor the names of its contributors 
19 #    may be used to endorse or promote products derived from this software 
20 #    without specific prior written permission. 
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
25 # ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
26 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
28 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
29 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
31 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
32 # SUCH DAMAGE. 
33 #
34 # $Id: check-context.in 22425 2008-01-13 09:46:01Z lha $
35 #
36
37 srcdir="@srcdir@"
38 objdir="@objdir@"
39
40 # If there is no useful db support compile in, disable test
41 ../db/have-db || exit 77
42
43 R=TEST.H5L.SE
44
45 port=@port@
46
47 keytabfile=${objdir}/server.keytab
48 keytab="FILE:${keytabfile}"
49 cache="FILE:krb5ccfile"
50
51 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
52 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
53 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
54
55 context="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context"
56
57 KRB5_CONFIG="${objdir}/krb5.conf"
58 export KRB5_CONFIG
59
60 KRB5CCNAME=${cache}
61 export KRB5CCNAME
62
63 rm -f ${keytabfile}
64 rm -f current-db*
65 rm -f out-*
66 rm -f mkey.file*
67
68 > messages.log
69
70 echo Creating database
71 ${kadmin} \
72     init \
73     --realm-max-ticket-life=1day \
74     --realm-max-renewable-life=1month \
75     ${R} || exit 1
76
77 # add both lucid and lucid.test.h5l.se to simulate aliases
78 ${kadmin} add -p p1 --use-defaults host/lucid.test.h5l.se@${R} || exit 1
79 ${kadmin} ext -k ${keytab} host/lucid.test.h5l.se@${R} || exit 1
80 ${kadmin} add -p p1 --use-defaults host/lucid@${R} || exit 1
81 ${kadmin} ext -k ${keytab} host/lucid@${R} || exit 1
82 ${kadmin} add -p kaka --use-defaults digest/${R}@${R} || exit 1
83
84 ${kadmin} add -p u1 --use-defaults user1@${R} || exit 1
85
86 echo "Doing database check"
87 ${kadmin} check ${R} || exit 1
88
89 echo u1 > ${objdir}/foopassword
90
91 echo Starting kdc
92 ${kdc} &
93 kdcpid=$!
94
95 sh ${srcdir}/../kdc/wait-kdc.sh
96 if [ "$?" != 0 ] ; then
97     kill ${kdcpid}
98     exit 1
99 fi
100
101 trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
102
103 exitcode=0
104
105 echo "Getting client initial tickets"
106 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode=1
107
108 echo "======test naming combinations"
109 echo "plain"
110 ${context} --name-type=hostbased-service host@lucid.test.h5l.se || \
111         { exitcode=1 ; echo test failed; }
112 echo "plain (krb5)"
113 ${context} --name-type=krb5-principal-name host/lucid.test.h5l.se@${R} || \
114         { exitcode=1 ; echo test failed; }
115 echo "plain (krb5 realmless)"
116 ${context} --name-type=krb5-principal-name host/lucid.test.h5l.se || \
117         { exitcode=1 ; echo test failed; }
118 echo "dns canon on (long name) OFF, need dns_wrapper"
119 #${context} --dns-canon host@lucid.test.h5l.se || \
120 #       { exitcode=1 ; echo test failed; }
121 echo "dns canon off (long name)"
122 ${context} --no-dns-canon host@lucid.test.h5l.se || \
123         { exitcode=1 ; echo test failed; }
124 echo "dns canon off (short name)"
125 ${context} --no-dns-canon host@lucid || \
126         { exitcode=1 ; echo test failed; }
127 echo "dns canon off (short name, krb5)"
128 ${context}  --no-dns-canon --name-type=krb5-principal-name host/lucid@${R} || \
129         { exitcode=1 ; echo test failed; }
130 echo "dns canon off (short name, krb5)"
131 ${context}  --no-dns-canon --name-type=krb5-principal-name host/lucid || \
132         { exitcode=1 ; echo test failed; }
133
134 echo "======test context building"
135 for mech in krb5 spnego ; do
136         echo "${mech} no-mutual"
137         ${context} --mech-type=${mech} \
138             --name-type=hostbased-service host@lucid.test.h5l.se || \
139                 { exitcode=1 ; echo test failed; }
140
141         echo "${mech} mutual"
142         ${context} --mech-type=${mech} \
143             --mutual \
144             --name-type=hostbased-service host@lucid.test.h5l.se || \
145                 { exitcode=1 ; echo test failed; }
146
147         echo "${mech} delegate"
148         ${context} --mech-type=${mech} \
149             --delegate \
150             --name-type=hostbased-service host@lucid.test.h5l.se || \
151                 { exitcode=1 ; echo test failed; }
152
153         echo "${mech} mutual delegate"
154         ${context} --mech-type=${mech} \
155             --mutual --delegate \
156             --name-type=hostbased-service host@lucid.test.h5l.se || \
157                 { exitcode=1 ; echo test failed; }
158 done
159
160 #add spnego !
161 echo "======dce-style"
162 for mech in krb5 ; do
163
164         echo "${mech}: dce-style"
165         ${context} \
166             --mech-type=${mech} \
167             --mutual \
168             --dce-style \
169             --name-type=hostbased-service host@lucid.test.h5l.se || \
170             { exitcode=1 ; echo test failed; }
171
172 done
173
174 #echo "sasl-digest-md5"
175 #${context}  --mech-type=sasl-digest-md5 \
176 #    --name-type=hostbased-service \
177 #    host@lucid.test.h5l.se || \
178 #       { exitcode=1 ; echo test failed; }
179
180
181 trap "" EXIT
182
183 echo "killing kdc (${kdcpid})"
184 kill ${kdcpid} 2> /dev/null
185
186 exit $exitcode
187
188