r22235: Test kinit, and PKINIT functionality by means of a new blackbox test.
[garming/samba-autobuild/.git] / testprogs / blackbox / test_kinit.sh
1 #!/bin/sh
2
3 if [ $# -lt 5 ]; then
4 cat <<EOF
5 Usage: test_kinit.sh SERVER USERNAME PASSWORD REALM PREFIX
6 EOF
7 exit 1;
8 fi
9
10 SERVER=$1
11 USERNAME=$2
12 PASSWORD=$3
13 REALM=$4
14 PREFIX=$5
15 shift 5
16 failed=0
17
18 testit() {
19         name="$1"
20         shift
21         cmdline="$*"
22         echo "test: $name"
23         $cmdline
24         status=$?
25         if [ x$status = x0 ]; then
26                 echo "success: $name"
27         else
28                 echo "failure: $name"
29         fi
30         return $status
31 }
32
33 KRB5CCNAME=`pwd`/tmpccache
34 export KRB5CCNAME
35
36 echo $PASSWORD > ./tmppassfile
37 testit "kinit with password" samba4kinit --password-file=./tmppassfile --request-pac $USERNAME@$REALM   || failed=`expr $failed + 1`
38 testit "kinit with pkinit" samba4kinit --request-pac --pk-user=FILE:$PREFIX/dc/private/tls/admincert.pem,$PREFIX/dc/private/tls/adminkey.pem $USERNAME@$REALM || failed=`expr $failed + 1`
39
40 echo ls | testit "Test login with kerberos ccache" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -k yes || failed=`expr $failed + 1`
41
42 testit "domain join with kerberos ccache" $VALGRIND bin/net join $DOMAIN $CONFIGURATION  -W "$DOMAIN" -k yes $@
43
44 rm -f tmpccfile tmppassfile
45 exit $failed