lib:ldb: Use correct integer types for sizes
[vlendec/samba-autobuild/.git] / nsswitch / tests / test_wbinfo_user_info_cached.sh
1 #!/bin/sh
2 # Blackbox test for wbinfo primary groups and samlogon caching
3 # Copyright (c) 2020 Andreas Schneider <asn@samba.org>
4
5 if [ $# -lt 5 ]; then
6         cat <<EOF
7 Usage: $(basename $0) DOMAIN REALM USERNAME PASSWORD PRIMARY_GROUP
8 EOF
9         exit 1
10 fi
11
12 DOMAIN=$1
13 REALM=$2
14 USERNAME=$3
15 PASSWORD=$4
16 PRIMARY_GROUP=$5
17 shift 5
18
19 DEFAULT_GROUP="Domain Users"
20
21 failed=0
22
23 samba_bindir="$BINDIR"
24 wbinfo_tool="$VALGRIND $samba_bindir/wbinfo"
25 net_tool="$VALGRIND $samba_bindir/net --configfile=$SERVERCONFFILE"
26
27 . $(dirname $0)/../../testprogs/blackbox/subunit.sh
28
29 KRB5CCNAME_PATH="$PREFIX/test_wbinfo_user_info_cached_krb5ccache"
30 rm -f $KRB5CCNAME_PATH
31
32 KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
33 export KRB5CCNAME
34
35 USER="$DOMAIN/$USERNAME"
36 USER_SID=$($wbinfo_tool --name-to-sid="$USER" | sed -e 's/ .*//')
37
38 testit_grep "user_info.no_cache" "$DEFAULT_GROUP" $wbinfo_tool --user-info=$USER || failed=$(expr $failed + 1)
39
40 # Fill the samlogon cache
41 testit "kerberos_login" $wbinfo_tool --krb5ccname=$KRB5CCNAME --krb5auth=$USER%$PASSWORD || failed=$(expr $failed + 1)
42
43 testit_grep "user_info.samlogon_cache" "$PRIMARY_GROUP" $wbinfo_tool --user-info=$USER || failed=$(expr $failed + 1)
44
45 # Cleanup
46 $net_tool cache samlogon delete $USER_SID
47
48 rm -f $KRB5CCNAME_PATH
49
50 exit $failed