1 1.1 elric #!/bin/sh 2 1.1 elric # 3 1.1 elric # Copyright (c) 2006 - 2007 Kungliga Tekniska Hgskolan 4 1.1 elric # (Royal Institute of Technology, Stockholm, Sweden). 5 1.1 elric # All rights reserved. 6 1.1 elric # 7 1.1 elric # Redistribution and use in source and binary forms, with or without 8 1.1 elric # modification, are permitted provided that the following conditions 9 1.1 elric # are met: 10 1.1 elric # 11 1.1 elric # 1. Redistributions of source code must retain the above copyright 12 1.1 elric # notice, this list of conditions and the following disclaimer. 13 1.1 elric # 14 1.1 elric # 2. Redistributions in binary form must reproduce the above copyright 15 1.1 elric # notice, this list of conditions and the following disclaimer in the 16 1.1 elric # documentation and/or other materials provided with the distribution. 17 1.1 elric # 18 1.1 elric # 3. Neither the name of the Institute nor the names of its contributors 19 1.1 elric # may be used to endorse or promote products derived from this software 20 1.1 elric # without specific prior written permission. 21 1.1 elric # 22 1.1 elric # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23 1.1 elric # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 1.1 elric # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 1.1 elric # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26 1.1 elric # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 1.1 elric # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 1.1 elric # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 1.1 elric # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 1.1 elric # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 1.1 elric # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 1.1 elric # SUCH DAMAGE. 33 1.1 elric 34 1.1 elric top_builddir="@top_builddir@" 35 1.1 elric env_setup="@env_setup@" 36 1.1 elric objdir="@objdir@" 37 1.1 elric 38 1.1 elric . ${env_setup} 39 1.1 elric 40 1.1 elric testfailed="echo test failed; cat messages.log; exit 1" 41 1.1 elric 42 1.1.1.4 christos # If there is no useful db support compiled in, disable test 43 1.1 elric ${have_db} || exit 77 44 1.1 elric 45 1.1 elric R=TEST.H5L.SE 46 1.1 elric R2=SUB.TEST.H5L.SE 47 1.1 elric 48 1.1.1.3 christos service=ldap/host.sub.test.h5l.se:389 49 1.1 elric 50 1.1 elric port=@port@ 51 1.1 elric 52 1.1 elric kadmin="${kadmin} -l -r $R" 53 1.1 elric kdc="${kdc} --addresses=localhost -P $port" 54 1.1 elric 55 1.1 elric cache="FILE:${objdir}/cache.krb5" 56 1.1 elric 57 1.1 elric kinit="${kinit} -c $cache ${afs_no_afslog}" 58 1.1 elric klist="${klist} -c $cache" 59 1.1 elric kgetcred="${kgetcred} -c $cache" 60 1.1 elric kdestroy="${kdestroy} -c $cache ${afs_no_unlog}" 61 1.1 elric 62 1.1 elric KRB5_CONFIG="${objdir}/krb5.conf" 63 1.1 elric export KRB5_CONFIG 64 1.1 elric 65 1.1 elric rm -f current-db* 66 1.1 elric rm -f out-* 67 1.1 elric rm -f mkey.file* 68 1.1 elric 69 1.1 elric > messages.log 70 1.1 elric 71 1.1 elric echo Creating database 72 1.1 elric ${kadmin} \ 73 1.1 elric init \ 74 1.1 elric --realm-max-ticket-life=1day \ 75 1.1 elric --realm-max-renewable-life=1month \ 76 1.1 elric ${R} || exit 1 77 1.1 elric 78 1.1 elric ${kadmin} \ 79 1.1 elric init \ 80 1.1 elric --realm-max-ticket-life=1day \ 81 1.1 elric --realm-max-renewable-life=1month \ 82 1.1 elric ${R2} || exit 1 83 1.1 elric 84 1.1 elric ${kadmin} add -p foo --use-defaults foo@${R} || exit 1 85 1.1 elric ${kadmin} modify --alias=alias1 --alias=alias2 foo@${R} || exit 1 86 1.1 elric ${kadmin} get foo@${R} | grep alias1@${R} >/dev/null || exit 1 87 1.1 elric 88 1.1 elric ${kadmin} add -p foo --use-defaults ${service}@${R2} || exit 1 89 1.1 elric 90 1.1 elric ${kadmin} add -p foo --use-defaults bar@${R} || exit 1 91 1.1 elric ${kadmin} add -p foo --use-defaults 'baz\@realm.foo@'${R} || exit 1 92 1.1 elric 93 1.1 elric ${kadmin} add -p cross1 --use-defaults krbtgt/${R2}@${R} || exit 1 94 1.1 elric ${kadmin} add -p cross2 --use-defaults krbtgt/${R}@${R2} || exit 1 95 1.1 elric 96 1.1 elric echo "Doing database check" 97 1.1 elric ${kadmin} check ${R} || exit 1 98 1.1 elric ${kadmin} check ${R2} || exit 1 99 1.1 elric 100 1.1 elric echo foo > ${objdir}/foopassword 101 1.1 elric 102 1.1.1.3 christos echo Starting kdc ; > messages.log 103 1.1.1.3 christos ${kdc} --detach --testing || { echo "kdc failed to start"; exit 1; } 104 1.1.1.3 christos kdcpid=`getpid kdc` 105 1.1 elric 106 1.1 elric trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT 107 1.1 elric 108 1.1 elric ec=0 109 1.1 elric 110 1.1 elric 111 1.1 elric echo "Getting client bar"; > messages.log 112 1.1 elric ${kinit} --password-file=${objdir}/foopassword bar@${R} || \ 113 1.1 elric { ec=1 ; eval "${testfailed}"; } 114 1.1 elric echo "checking that we got back right principal" 115 1.1 elric ${klist} | grep "Principal: bar@${R}" > /dev/null || \ 116 1.1 elric { ec=1 ; eval "${testfailed}"; } 117 1.1 elric ${kdestroy} 118 1.1 elric 119 1.1 elric echo "Getting client baz"; > messages.log 120 1.1 elric ${kinit} --password-file=${objdir}/foopassword 'baz\@realm.foo@'${R} || \ 121 1.1 elric { ec=1 ; eval "${testfailed}"; } 122 1.1 elric echo "checking that we got back right principal" 123 1.1 elric ${klist} | grep 'Principal: baz' > /dev/null || \ 124 1.1 elric { ec=1 ; eval "${testfailed}"; } 125 1.1 elric ${kdestroy} 126 1.1 elric 127 1.1 elric 128 1.1 elric 129 1.1 elric echo "Test AS-REQ" 130 1.1 elric 131 1.1 elric echo "Getting client (no canon)"; > messages.log 132 1.1 elric ${kinit} --password-file=${objdir}/foopassword foo@${R} || \ 133 1.1 elric { ec=1 ; eval "${testfailed}"; } 134 1.1 elric echo "checking that we got back right principal" 135 1.1 elric ${klist} | grep "Principal: foo@${R}" > /dev/null || \ 136 1.1 elric { ec=1 ; eval "${testfailed}"; } 137 1.1 elric ${kdestroy} 138 1.1 elric 139 1.1 elric echo "Getting client client tickets (default realm, enterprisename)"; > messages.log 140 1.1 elric ${kinit} --canonicalize \ 141 1.1 elric --password-file=${objdir}/foopassword foo@${R} || \ 142 1.1 elric { ec=1 ; eval "${testfailed}"; } 143 1.1 elric echo "checking that we got back right principal" 144 1.1 elric ${klist} | grep "Principal: foo@${R}" > /dev/null || \ 145 1.1 elric { ec=1 ; eval "${testfailed}"; } 146 1.1 elric ${kdestroy} 147 1.1 elric 148 1.1 elric echo "Getting client alias1 tickets"; > messages.log 149 1.1 elric ${kinit} --canonicalize \ 150 1.1 elric --password-file=${objdir}/foopassword foo@${R} || \ 151 1.1 elric { ec=1 ; eval "${testfailed}"; } 152 1.1 elric echo "checking that we got back right principal" 153 1.1 elric ${klist} | grep "Principal: foo@${R}" > /dev/null || \ 154 1.1 elric { ec=1 ; eval "${testfailed}"; } 155 1.1 elric ${kdestroy} 156 1.1 elric 157 1.1 elric 158 1.1 elric echo "Getting client alias2 tickets"; > messages.log 159 1.1 elric ${kinit} --canonicalize \ 160 1.1 elric --password-file=${objdir}/foopassword alias2@${R}@${R} || \ 161 1.1 elric { ec=1 ; eval "${testfailed}"; } 162 1.1 elric echo "checking that we got back right principal" 163 1.1 elric ${klist} | grep "Principal: foo@${R}" > /dev/null || \ 164 1.1 elric { ec=1 ; eval "${testfailed}"; } 165 1.1 elric ${kdestroy} 166 1.1 elric 167 1.1 elric echo "Getting client alias1 tickets (non canon case)"; > messages.log 168 1.1 elric ${kinit} --password-file=${objdir}/foopassword \ 169 1.1 elric alias1@${R}@${R} > /dev/null 2>/dev/null && \ 170 1.1 elric { ec=1 ; eval "${testfailed}"; } 171 1.1 elric 172 1.1 elric echo "Getting client alias2 tickets (removed)"; > messages.log 173 1.1 elric ${kadmin} modify --alias=alias1 foo@${R} || { ec=1 ; eval "${testfailed}"; } 174 1.1 elric ${kinit} --canonicalize \ 175 1.1 elric --password-file=${objdir}/foopassword \ 176 1.1 elric alias2@${R}@${R} > /dev/null 2>/dev/null && \ 177 1.1 elric { ec=1 ; eval "${testfailed}"; } 178 1.1 elric 179 1.1 elric echo "Remove alias" 180 1.1 elric ${kadmin} modify --alias= foo@${R} || { ec=1 ; eval "${testfailed}"; } 181 1.1 elric 182 1.1 elric echo "Test server referrals" 183 1.1 elric 184 1.1 elric echo "Getting client for ${service}@${R} (tgs kdc referral)" 185 1.1 elric > messages.log 186 1.1 elric ${kinit} --password-file=${objdir}/foopassword foo@${R} || \ 187 1.1 elric { ec=1 ; eval "${testfailed}"; } 188 1.1 elric ${kgetcred} --canonicalize ${service}@${R} || 189 1.1 elric { ec=1 ; eval "${testfailed}"; } 190 1.1 elric echo "checking that we got back right principal" 191 1.1 elric ${klist} | grep "${service}@${R2}" > /dev/null || \ 192 1.1 elric { ec=1 ; eval "${testfailed}"; } 193 1.1 elric ${kdestroy} 194 1.1 elric 195 1.1 elric echo "Getting client for ${service}@${R2} (tgs client side guessing)" 196 1.1 elric > messages.log 197 1.1 elric ${kinit} --password-file=${objdir}/foopassword foo@${R} || \ 198 1.1 elric { ec=1 ; eval "${testfailed}"; } 199 1.1 elric ${kgetcred} ${service}@${R2} || 200 1.1 elric { ec=1 ; eval "${testfailed}"; } 201 1.1 elric echo "checking that we got back right principal" 202 1.1 elric ${klist} | grep "${service}@${R2}" > /dev/null || \ 203 1.1 elric { ec=1 ; eval "${testfailed}"; } 204 1.1 elric ${kdestroy} 205 1.1 elric 206 1.1 elric 207 1.1 elric echo "killing kdc (${kdcpid})" 208 1.1 elric sh ${leaks_kill} kdc $kdcpid || exit 1 209 1.1 elric 210 1.1 elric trap "" EXIT 211 1.1 elric 212 1.1 elric exit $ec 213