source: vendor/3.6.0/testprogs/blackbox/test_kinit.sh

Last change on this file was 740, checked in by Silvan Scherrer, 13 years ago

Samba Server: update vendor to 3.6.0

File size: 7.5 KB
Line 
1#!/bin/sh
2# Blackbox tests for kinit and kerberos integration with smbclient etc
3# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
4# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
5
6if [ $# -lt 5 ]; then
7cat <<EOF
8Usage: test_kinit.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
9EOF
10exit 1;
11fi
12
13SERVER=$1
14USERNAME=$2
15PASSWORD=$3
16REALM=$4
17DOMAIN=$5
18PREFIX=$6
19ENCTYPE=$7
20shift 7
21failed=0
22
23samba4bindir="$BUILDDIR/bin"
24samba4srcdir="$SRCDIR/source4"
25smbclient="$samba4bindir/smbclient$EXEEXT"
26samba4kinit="$samba4bindir/samba4kinit$EXEEXT"
27samba_tool="$samba4bindir/samba-tool$EXEEXT"
28ldbmodify="$samba4bindir/ldbmodify$EXEEXT"
29ldbsearch="$samba4bindir/ldbsearch$EXEEXT"
30rkpty="$samba4bindir/rkpty$EXEEXT"
31samba4kpasswd="$samba4bindir/samba4kpasswd$EXEEXT"
32enableaccount="$samba_tool enableaccount"
33machineaccountccache="$samba4srcdir/scripting/bin/machineaccountccache"
34
35. `dirname $0`/subunit.sh
36
37test_smbclient() {
38 name="$1"
39 cmd="$2"
40 shift
41 shift
42 echo "test: $name"
43 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" $@
44 status=$?
45 if [ x$status = x0 ]; then
46 echo "success: $name"
47 else
48 echo "failure: $name"
49 fi
50 return $status
51}
52
53enctype="-e $ENCTYPE"
54
55PWSETCONFIG="-H ldap://$SERVER -U$USERNAME%$PASSWORD"
56export PWSETCONFIG
57
58KRB5CCNAME="$PREFIX/tmpccache"
59export KRB5CCNAME
60
61testit "reset password policies beside of minimum password age of 0 days" $VALGRIND $samba_tool pwsettings $PWSETCONFIG set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default || failed=`expr $failed + 1`
62
63echo $PASSWORD > $PREFIX/tmppassfile
64#testit "kinit with keytab" $samba4kinit $enctype --keytab=$PREFIX/dc/private/secrets.keytab $SERVER\$@$REALM || failed=`expr $failed + 1`
65testit "kinit with password" $samba4kinit $enctype --password-file=$PREFIX/tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
66testit "kinit with password (enterprise style)" $samba4kinit $enctype --enterprise --password-file=$PREFIX/tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
67testit "kinit with password (windows style)" $samba4kinit $enctype --renewable --windows --password-file=$PREFIX/tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
68testit "kinit renew ticket" $samba4kinit $enctype --request-pac -R
69
70test_smbclient "Test login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
71
72testit "check time with kerberos ccache" $VALGRIND $samba_tool $CONFIGURATION -k yes $@ time $SERVER || failed=`expr $failed + 1`
73
74USERPASS=testPass@12%
75echo $USERPASS > $PREFIX/tmpuserpassfile
76testit "add user with kerberos ccache" $VALGRIND $samba_tool user add nettestuser $USERPASS $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
77
78echo "Getting defaultNamingContext"
79BASEDN=`$ldbsearch $options --basedn='' -H ldap://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
80
81cat > $PREFIX/tmpldbmodify <<EOF
82dn: cn=nettestuser,cn=users,$BASEDN
83changetype: modify
84add: servicePrincipalName
85servicePrincipalName: host/nettestuser
86EOF
87
88testit "modify servicePrincipalName" $VALGRIND $ldbmodify -H ldap://$SERVER $PREFIX/tmpldbmodify -k yes $@ || failed=`expr $failed + 1`
89
90testit "set user password with kerberos ccache" $VALGRIND $samba_tool password set $DOMAIN\\nettestuser $USERPASS $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
91
92testit "enable user with kerberos cache" $VALGRIND $enableaccount nettestuser -H ldap://$SERVER -k yes $@ || failed=`expr $failed + 1`
93
94KRB5CCNAME="$PREFIX/tmpuserccache"
95export KRB5CCNAME
96
97testit "kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
98
99test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
100
101NEWUSERPASS=testPaSS@34%
102testit "change user password with 'samba-tool password change' (rpc)" $VALGRIND $samba_tool password change -W$DOMAIN -U$DOMAIN\\nettestuser%$USERPASS $CONFIGURATION -k no $NEWUSERPASS $@ || failed=`expr $failed + 1`
103
104echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
105testit "kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
106
107test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
108
109
110USERPASS=$NEWUSERPASS
111NEWUSERPASS=testPaSS@56%
112echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
113
114cat > $PREFIX/tmpkpasswdscript <<EOF
115expect Password
116password ${USERPASS}\n
117expect New password
118send ${NEWUSERPASS}\n
119expect Verify password
120send ${NEWUSERPASS}\n
121expect Success
122EOF
123
124testit "change user password with kpasswd" $rkpty $PREFIX/tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
125
126testit "kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
127
128NEWUSERPASS=testPaSS@78%
129echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
130
131test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
132
133cat > $PREFIX/tmpkpasswdscript <<EOF
134expect New password
135send ${NEWUSERPASS}\n
136expect Verify password
137send ${NEWUSERPASS}\n
138expect Success
139EOF
140
141testit "set user password with kpasswd" $rkpty $PREFIX/tmpkpasswdscript $samba4kpasswd --cache=$PREFIX/tmpccache nettestuser@$REALM || failed=`expr $failed + 1`
142
143testit "kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
144
145test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
146
147NEWUSERPASS=testPaSS@910%
148echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
149
150cat > $PREFIX/tmpkpasswdscript <<EOF
151expect New password
152send ${NEWUSERPASS}\n
153expect Verify password
154send ${NEWUSERPASS}\n
155expect Success
156EOF
157
158testit "set user password with kpasswd and servicePrincipalName" $rkpty $PREFIX/tmpkpasswdscript $samba4kpasswd --cache=$PREFIX/tmpccache host/nettestuser@$REALM || failed=`expr $failed + 1`
159
160testit "kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
161
162test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
163
164KRB5CCNAME="$PREFIX/tmpccache"
165export KRB5CCNAME
166
167lowerrealm=$(echo $REALM | tr '[A-Z]' '[a-z]')
168test_smbclient "Test login with user kerberos lowercase realm" 'ls' -k yes -Unettestuser@$lowerrealm%$NEWUSERPASS || failed=`expr $failed + 1`
169test_smbclient "Test login with user kerberos lowercase realm 2" 'ls' -k yes -Unettestuser@$REALM%$NEWUSERPASS --realm=$lowerrealm || failed=`expr $failed + 1`
170
171testit "del user with kerberos ccache" $VALGRIND $samba_tool user delete nettestuser $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
172
173rm -f $KRB5CCNAME
174testit "kinit with machineaccountccache script" $machineaccountccache $CONFIGURATION $KRB5CCNAME || failed=`expr $failed + 1`
175test_smbclient "Test machine account login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
176
177testit "reset password policies" $VALGRIND $samba_tool pwsettings $PWSETCONFIG set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default || failed=`expr $failed + 1`
178
179rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
180exit $failed
Note: See TracBrowser for help on using the repository browser.