use DES_set_key_unchecked().
[heimdal.git] / tests / gss / check-context.in
bloba19d5b7d3237108e77150a68338ee1154d15df1f
1 #!/bin/sh
3 # Copyright (c) 2006 - 2008 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
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.
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.
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.
34 # $Id$
37 srcdir="@srcdir@"
38 objdir="@objdir@"
40 # If there is no useful db support compile in, disable test
41 ../db/have-db || exit 77
43 R=TEST.H5L.SE
45 port=@port@
47 keytabfile=${objdir}/server.keytab
48 keytab="FILE:${keytabfile}"
49 nokeytab="FILE:no-such-keytab"
50 cache="FILE:krb5ccfile"
52 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
53 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
54 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
56 context="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context"
58 KRB5_CONFIG="${objdir}/krb5.conf"
59 export KRB5_CONFIG
61 KRB5CCNAME=${cache}
62 export KRB5CCNAME
64 rm -f ${keytabfile}
65 rm -f current-db*
66 rm -f out-*
67 rm -f mkey.file*
69 > messages.log
71 echo Creating database
72 ${kadmin} \
73 init \
74 --realm-max-ticket-life=1day \
75 --realm-max-renewable-life=1month \
76 ${R} || exit 1
78 # add both lucid and lucid.test.h5l.se to simulate aliases
79 ${kadmin} add -p p1 --use-defaults host/lucid.test.h5l.se@${R} || exit 1
80 ${kadmin} ext -k ${keytab} host/lucid.test.h5l.se@${R} || exit 1
81 ${kadmin} add -p p1 --use-defaults host/lucid@${R} || exit 1
82 ${kadmin} ext -k ${keytab} host/lucid@${R} || exit 1
83 ${kadmin} add -p kaka --use-defaults digest/${R}@${R} || exit 1
85 ${kadmin} add -p u1 --use-defaults user1@${R} || exit 1
87 echo "Doing database check"
88 ${kadmin} check ${R} || exit 1
90 echo u1 > ${objdir}/foopassword
92 echo Starting kdc
93 ${kdc} &
94 kdcpid=$!
96 sh ${srcdir}/../kdc/wait-kdc.sh
97 if [ "$?" != 0 ] ; then
98 kill ${kdcpid}
99 exit 1
102 trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
104 exitcode=0
106 echo "Getting client initial tickets"
107 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode=1
109 echo "======test unreadable/non existant keytab and its error message"
110 ${context} --mech-type=krb5 host@lucid.test.h5l.se || \
111 { exitcode=1 ; echo "test failed"; }
113 mv ${keytabfile} ${keytabfile}.no
115 echo "checking non existant keytabfile (krb5)"
116 ${context} --mech-type=krb5 host@lucid.test.h5l.se > test_context.log 2>&1 && \
117 { exitcode=1 ; echo "test failed"; }
118 grep ${keytabfile} test_context.log > /dev/null || \
119 { exitcode=1 ; echo "test failed"; }
120 echo "checking non existant keytabfile (spengo)"
121 ${context} --mech-type=spnego host@lucid.test.h5l.se > test_context.log 2>&1 && \
122 { exitcode=1 ; echo "test failed"; }
123 grep ${keytabfile} test_context.log > /dev/null || \
124 { exitcode=1 ; echo "test failed"; }
126 mv ${keytabfile}.no ${keytabfile}
128 echo "======test naming combinations"
129 echo "plain"
130 ${context} --name-type=hostbased-service host@lucid.test.h5l.se || \
131 { exitcode=1 ; echo "test failed"; }
132 echo "plain (krb5)"
133 ${context} --name-type=krb5-principal-name host/lucid.test.h5l.se@${R} || \
134 { exitcode=1 ; echo "test failed"; }
135 echo "plain (krb5 realmless)"
136 ${context} --name-type=krb5-principal-name host/lucid.test.h5l.se || \
137 { exitcode=1 ; echo "test failed"; }
138 echo "dns canon on (long name) OFF, need dns_wrapper"
139 #${context} --dns-canon host@lucid.test.h5l.se || \
140 # { exitcode=1 ; echo "test failed"; }
141 echo "dns canon off (long name)"
142 ${context} --no-dns-canon host@lucid.test.h5l.se || \
143 { exitcode=1 ; echo "test failed"; }
144 echo "dns canon off (short name)"
145 ${context} --no-dns-canon host@lucid || \
146 { exitcode=1 ; echo "test failed"; }
147 echo "dns canon off (short name, krb5)"
148 ${context} --no-dns-canon --name-type=krb5-principal-name host/lucid@${R} || \
149 { exitcode=1 ; echo "test failed"; }
150 echo "dns canon off (short name, krb5)"
151 ${context} --no-dns-canon --name-type=krb5-principal-name host/lucid || \
152 { exitcode=1 ; echo "test failed"; }
154 echo "======test context building"
155 for mech in krb5 spnego ; do
156 echo "${mech} no-mutual"
157 ${context} --mech-type=${mech} \
158 --name-type=hostbased-service host@lucid.test.h5l.se || \
159 { exitcode=1 ; echo "test failed"; }
161 echo "${mech} mutual"
162 ${context} --mech-type=${mech} \
163 --mutual \
164 --name-type=hostbased-service host@lucid.test.h5l.se || \
165 { exitcode=1 ; echo "test failed"; }
167 echo "${mech} delegate"
168 ${context} --mech-type=${mech} \
169 --delegate \
170 --name-type=hostbased-service host@lucid.test.h5l.se || \
171 { exitcode=1 ; echo "test failed"; }
173 echo "${mech} mutual delegate"
174 ${context} --mech-type=${mech} \
175 --mutual --delegate \
176 --name-type=hostbased-service host@lucid.test.h5l.se || \
177 { exitcode=1 ; echo "test failed"; }
178 done
180 #add spnego !
181 echo "======dce-style"
182 for mech in krb5 ; do
184 echo "${mech}: dce-style"
185 ${context} \
186 --mech-type=${mech} \
187 --mutual \
188 --dce-style \
189 --name-type=hostbased-service host@lucid.test.h5l.se || \
190 { exitcode=1 ; echo "test failed"; }
192 done
194 echo "test gsskrb5_register_acceptor_identity (both positive and negative)"
196 cp ${keytabfile} ${keytabfile}.new
197 for mech in krb5 spnego; do
198 echo "${mech}: acceptor_identity positive"
199 ${context} --gsskrb5-acceptor-identity=${keytabfile}.new \
200 --mech-type=$mech host@lucid.test.h5l.se || \
201 { exitcode=1 ; echo "test failed"; }
203 echo "${mech}: acceptor_identity negative"
204 ${context} --gsskrb5-acceptor-identity=${keytabfile}.foo \
205 --mech-type=$mech host@lucid.test.h5l.se 2>/dev/null && \
206 { exitcode=1 ; echo "test failed"; }
207 done
209 rm ${keytabfile}.new
212 #echo "sasl-digest-md5"
213 #${context} --mech-type=sasl-digest-md5 \
214 # --name-type=hostbased-service \
215 # host@lucid.test.h5l.se || \
216 # { exitcode=1 ; echo "test failed"; }
219 trap "" EXIT
221 echo "killing kdc (${kdcpid})"
222 kill ${kdcpid} 2> /dev/null
224 exit $exitcode