s3: smbd: printing: Re-implement delete-on-close semantics for print files missing...
[Samba.git] / nsswitch / tests / test_wbinfo_user_info.sh
blob2803ac1408bea42a577e7bd7e38a412f96fe4dee
1 #!/bin/sh
2 # Blackbox test for wbinfo lookup for account name and upn
3 # Copyright (c) 2018 Andreas Schneider <asn@samba.org>
5 if [ $# -lt 5 ]; then
6 cat <<EOF
7 Usage: $(basename $0) DOMAIN REALM USERNAME1 UPN_NAME1 USERNAME2 UPN_NAME2
8 EOF
9 exit 1;
12 DOMAIN=$1
13 REALM=$2
14 USERNAME1=$3
15 UPN_NAME1=$4
16 USERNAME2=$5
17 UPN_NAME2=$6
18 shift 6
20 failed=0
22 samba_bindir="$BINDIR"
23 wbinfo_tool="$VALGRIND $samba_bindir/wbinfo"
25 UPN1="$UPN_NAME1@$REALM"
26 UPN2="$UPN_NAME2@$REALM"
28 . $(dirname $0)/../../testprogs/blackbox/subunit.sh
30 test_user_info()
32 local cmd out ret user domain upn userinfo
34 domain="$1"
35 user="$2"
36 upn="$3"
38 if [ $# -lt 3 ]; then
39 userinfo="$domain/$user"
40 else
41 userinfo="$upn"
44 cmd='$wbinfo_tool --user-info $userinfo'
45 eval echo "$cmd"
46 out=$(eval $cmd)
47 ret=$?
48 if [ $ret -ne 0 ]; then
49 echo "failed to lookup $userinfo"
50 echo "$out"
51 return 1
54 echo "$out" | grep "$domain/$user:.*:.*:.*::/home/$domain/Domain Users/$user"
55 ret=$?
56 if [ $ret != 0 ]; then
57 echo "failed to lookup $userinfo"
58 echo "$out"
59 return 1
62 return 0
65 testit "name_to_sid.domain.$USERNAME1" $wbinfo_tool --name-to-sid $DOMAIN/$USERNAME1 || failed=$(expr $failed + 1)
66 testit "name_to_sid.upn.$UPN_NAME1" $wbinfo_tool --name-to-sid $UPN1 || failed=$(expr $failed + 1)
68 testit "user_info.domain.$USERNAME1" test_user_info $DOMAIN $USERNAME1 || failed=$(expr $failed + 1)
69 testit "user_info.upn.$UPN_NAME1" test_user_info $DOMAIN $USERNAME1 $UPN1 || failed=$(expr $failed + 1)
71 testit "name_to_sid.domain.$USERNAME2" $wbinfo_tool --name-to-sid $DOMAIN/$USERNAME2 || failed=$(expr $failed + 1)
72 testit "name_to_sid.upn.$UPN_NAME2" $wbinfo_tool --name-to-sid $UPN2 || failed=$(expr $failed + 1)
74 testit "user_info.domain.$USERNAME2" test_user_info $DOMAIN $USERNAME2 || failed=$(expr $failed + 1)
75 testit "user_info.upn.$UPN_NAME2" test_user_info $DOMAIN $USERNAME2 $UPN2 || failed=$(expr $failed + 1)
77 USERNAME3="testdenied"
78 UPN_NAME3="testdenied_upn"
79 UPN3="$UPN_NAME3@${REALM}.upn"
80 testit "name_to_sid.upn.$UPN_NAME3" $wbinfo_tool --name-to-sid $UPN3 || failed=$(expr $failed + 1)
81 testit "user_info.upn.$UPN_NAME3" test_user_info $DOMAIN $USERNAME3 $UPN3 || failed=$(expr $failed + 1)
83 exit $failed