2 # Blackbox test for wbinfo lookup for account name and upn
3 # Copyright (c) 2018 Andreas Schneider <asn@samba.org>
7 Usage: $(basename $0) DOMAIN REALM OWN_DOMAIN USERNAME1 UPN_NAME1 USERNAME2 UPN_NAME2 ENVNAME
24 samba_bindir="$BINDIR"
25 wbinfo_tool="$VALGRIND $samba_bindir/wbinfo"
27 UPN1="$UPN_NAME1@$REALM"
28 UPN2="$UPN_NAME2@$REALM"
30 . $(dirname $0)/../../testprogs/blackbox/subunit.sh
34 local cmd out ret user domain upn userinfo
41 userinfo="$domain/$user"
46 cmd='$wbinfo_tool --user-info $userinfo'
50 if [ $ret -ne 0 ]; then
51 echo "failed to lookup $userinfo"
56 echo "$out" | grep "$domain/$user:.*:.*:.*::/home/$domain/Domain Users/$user"
58 if [ $ret != 0 ]; then
59 echo "failed to lookup $userinfo"
71 local lookup_username=$1
72 local expected_return=$2
73 local expected_output=$3
75 cmd='getent passwd $lookup_username'
80 if [ $ret -ne $expected_return ]; then
81 echo "return code: $ret, expected return code is: $expected_return"
86 if [ -n "$expected_output" ]; then
87 echo "$out" | grep "$expected_output"
90 if [ $ret -ne 0 ]; then
91 echo "Unable to find $expected_output in:"
100 testit "name_to_sid.domain.$USERNAME1" $wbinfo_tool --name-to-sid $DOMAIN/$USERNAME1 || failed=$(expr $failed + 1)
101 testit "name_to_sid.upn.$UPN_NAME1" $wbinfo_tool --name-to-sid $UPN1 || failed=$(expr $failed + 1)
103 testit "user_info.domain.$USERNAME1" test_user_info $DOMAIN $USERNAME1 || failed=$(expr $failed + 1)
104 testit "user_info.upn.$UPN_NAME1" test_user_info $DOMAIN $USERNAME1 $UPN1 || failed=$(expr $failed + 1)
106 testit "name_to_sid.domain.$USERNAME2" $wbinfo_tool --name-to-sid $DOMAIN/$USERNAME2 || failed=$(expr $failed + 1)
107 testit "name_to_sid.upn.$UPN_NAME2" $wbinfo_tool --name-to-sid $UPN2 || failed=$(expr $failed + 1)
109 testit "user_info.domain.$USERNAME2" test_user_info $DOMAIN $USERNAME2 || failed=$(expr $failed + 1)
110 testit "user_info.upn.$UPN_NAME2" test_user_info $DOMAIN $USERNAME2 $UPN2 || failed=$(expr $failed + 1)
112 USERNAME3="testdenied"
113 UPN_NAME3="testdenied_upn"
114 UPN3="$UPN_NAME3@${REALM}.upn"
115 testit "name_to_sid.upn.$UPN_NAME3" $wbinfo_tool --name-to-sid $UPN3 || failed=$(expr $failed + 1)
116 testit "user_info.upn.$UPN_NAME3" test_user_info $DOMAIN $USERNAME3 $UPN3 || failed=$(expr $failed + 1)
118 testit "getpwnam.domain.$DOMAIN.$USERNAME1" test_getpwnam "$DOMAIN/$USERNAME1" 0 "$DOMAIN/$USERNAME1" || failed=$(expr $failed + 1)
120 testit "getpwnam.upn.$UPN_NAME1" test_getpwnam "$UPN1" 0 "$DOMAIN/$USERNAME1" || failed=$(expr $failed + 1)
124 # We should not be able to lookup the user just by the name
130 test_output="$OWN_DOMAIN/$USERNAME1"
134 test_output="$DOMAIN/$USERNAME1"
138 testit "getpwnam.local.$USERNAME1" test_getpwnam "$USERNAME1" $test_ret $test_output || failed=$(expr $failed + 1)