testprogs/blackbox: PY3 bulk change for python scripts use correct python
[garming/samba-autobuild/.git] / testprogs / blackbox / test_trust_user_account.sh
1 #!/bin/sh
2
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: test_trust_user_account.sh PREFIX OUR_REALM OUR_FLAT REMOTE_REALM REMOTE_FLAT
6 EOF
7 exit 1;
8 fi
9
10 PREFIX="$1"
11 OUR_REALM="$2"
12 OUR_FLAT="$3"
13 REMOTE_REALM="$4"
14 REMOTE_FLAT="$5"
15 shift 5
16
17 . `dirname $0`/subunit.sh
18
19
20 samba_tool="$BINDIR/samba-tool"
21 samba4bindir="$BINDIR"
22 samba4srcdir="$SRCDIR/source4"
23 samba4kinit="kinit -k"
24 if test -x $BINDIR/samba4kinit; then
25         samba4kinit="$BINDIR/samba4kinit --use-keytab"
26 fi
27
28 KEYTAB="$PREFIX/tmptda.keytab"
29
30 KRB5_TRACE=/dev/stderr
31 export KRB5_TRACE
32
33 testit "retrieve keytab for TDA of $REMOTE_REALM" $PYTHON $samba_tool domain exportkeytab $KEYTAB $CONFIGURATION --principal "$REMOTE_FLAT\$@$OUR_REALM" || failed=`expr $failed + 1`
34
35 KRB5CCNAME="$PREFIX/tmptda.ccache"
36 export KRB5CCNAME
37
38 rm -f $KRB5CCNAME
39
40 EXPECTED_SALT="${OUR_REALM}krbtgt${REMOTE_FLAT}"
41 #
42 # Note the \$ is for the end of line in grep
43 #
44 # There must be no trailing '$' in the SALT string itself,
45 # it's removed from the sAMAccountName value (which includes the trailing '$')
46 # before construting the salt!
47 #
48 # Otherwise this would be:
49 # "^virtualKerberosSalt: ${EXPECTED_SALT}\\\$\$"
50 #
51 EXPECTED_GREP="^virtualKerberosSalt: ${EXPECTED_SALT}\$"
52 testit_grep "get virtualKerberosSalt for TDA of $REMOTE_FLAT\$" "$EXPECTED_GREP" $PYTHON $samba_tool user getpassword "$REMOTE_FLAT\$" $CONFIGURATION --attributes=virtualKerberosSalt || failed=`expr $failed + 1`
53
54 testit "kinit with keytab for TDA of $REMOTE_REALM" $samba4kinit -t $KEYTAB "$REMOTE_FLAT\$@$OUR_REALM" || failed=`expr $failed + 1`
55
56 rm -f $KRB5CCNAME $KEYTAB
57
58 exit $failed