2 # Blackbox test for wbinfo
5 Usage: test_wbinfo.sh DOMAIN USERNAME PASSWORD TARGET
17 samba4bindir="$BINDIR"
18 wbinfo="$VALGRIND $samba4bindir/wbinfo"
20 . `dirname $0`/../../testprogs/blackbox/subunit.sh
29 if [ x$status = x0 ]; then
44 if [ x$status = x0 ]; then
45 echo "failure: $name [unexpected success]"
48 echo "knownfail: $name"
54 KRB5CCNAME_PATH="$PREFIX/test_wbinfo_krb5ccache"
55 rm -f $KRB5CCNAME_PATH
57 KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
61 testit "wbinfo -u against $TARGET" $wbinfo -u || failed=`expr $failed + 1`
63 testit "wbinfo -g against $TARGET" $wbinfo -g || failed=`expr $failed + 1`
64 # Convert netbios name to IP
66 testit "wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed=`expr $failed + 1`
67 # Convert IP to netbios name
69 testit "wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed=`expr $failed + 1`
72 testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
73 admin_sid=`$wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1`
74 echo "$DOMAIN/$USERNAME resolved to $admin_sid"
76 testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=`expr $failed + 1`
77 admin_name=`$wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z`
78 echo "$admin_sid resolved to $admin_name"
80 tested_name=`echo $DOMAIN/$USERNAME | tr a-z A-Z`
82 echo "test: wbinfo -s check for sane mapping"
83 if test x$admin_name != x$tested_name; then
84 echo "$admin_name does not match $tested_name"
85 echo "failure: wbinfo -s check for sane mapping"
86 failed=`expr $failed + 1`
88 echo "success: wbinfo -s check for sane mapping"
94 testit "wbinfo -s $SID against $TARGET" $wbinfo -s $SID || failed=`expr $failed + 1`
96 RESOLVED_NAME=`$wbinfo -s $SID | tr a-z A-Z`
97 echo "$SID resolved to $RESOLVED_NAME"
99 echo "test: wbinfo -s $SID against $TARGET"
100 if test x"$RESOLVED_NAME" != x"$NAME" ; then
101 echo "$RESOLVED_NAME does not match $NAME"
102 echo "failure: wbinfo -s $SID against $TARGET"
103 failed=`expr $failed + 1`
105 echo "success: wbinfo -s $SID against $TARGET"
113 NT AUTHORITY/DIALUP 5
116 testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed=`expr $failed + 1`
117 test_sid=`$wbinfo -n $tested_name | cut -d " " -f1`
119 echo "test: wbinfo -n check for sane mapping"
120 if test x$admin_sid != x$test_sid; then
121 echo "$admin_sid does not match $test_sid"
122 echo "failure: wbinfo -n check for sane mapping"
123 failed=`expr $failed + 1`
125 echo "success: wbinfo -n check for sane mapping"
128 echo "test: wbinfo -n NT Authority/Authenticated Users"
129 $wbinfo -n "NT Authority/Authenticated Users"
130 if [ $? -ne 0 ] ; then
131 echo "failure: wbinfo -n NT Authority/Authenticated Users"
132 failed=`expr $failed + 1`
134 echo "success: wbinfo -n NT Authority/Authenticated Users"
137 echo "test: wbinfo --group-info NT Authority/Authenticated Users"
138 $wbinfo --group-info "NT Authority/Authenticated Users"
139 if [ $? -ne 0 ] ; then
140 echo "failure: wbinfo --group-info NT Authority/Authenticated Users"
141 failed=`expr $failed + 1`
143 echo "success: wbinfo --group-info NT Authority/Authenticated Users"
146 testit "wbinfo -U against $TARGET" $wbinfo -U 30000 || failed=`expr $failed + 1`
148 echo "test: wbinfo -U check for sane mapping"
149 sid_for_30000=`$wbinfo -U 30000`
150 if test x$sid_for_30000 != "xS-1-22-1-30000"; then
151 echo "uid 30000 mapped to $sid_for_30000, not S-1-22-1-30000"
152 echo "failure: wbinfo -U check for sane mapping"
153 failed=`expr $failed + 1`
155 echo "success: wbinfo -U check for sane mapping"
158 admin_uid=`$wbinfo -S $admin_sid`
160 testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=`expr $failed + 1`
162 echo "test: wbinfo -G check for sane mapping"
163 sid_for_30000=`$wbinfo -G 30000`
164 if test x$sid_for_30000 != "xS-1-22-2-30000"; then
165 echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
166 echo "failure: wbinfo -G check for sane mapping"
167 failed=`expr $failed + 1`
169 echo "success: wbinfo -G check for sane mapping"
172 testit "wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed=`expr $failed + 1`
174 echo "test: wbinfo -S check for sane mapping"
175 uid_for_sid=`$wbinfo -S S-1-22-1-30000`
176 if test 0$uid_for_sid -ne 30000; then
177 echo "S-1-22-1-30000 mapped to $uid_for_sid, not 30000"
178 echo "failure: wbinfo -S check for sane mapping"
179 failed=`expr $failed + 1`
181 echo "success: wbinfo -S check for sane mapping"
184 testfail "wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed=`expr $failed + 1`
186 testit "wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed=`expr $failed + 1`
188 echo "test: wbinfo -Y check for sane mapping"
189 gid_for_sid=`$wbinfo -Y S-1-22-2-30000`
190 if test 0$gid_for_sid -ne 30000; then
191 echo "S-1-22-2-30000 mapped to $gid_for_sid, not 30000"
192 echo "failure: wbinfo -Y check for sane mapping"
193 failed=`expr $failed + 1`
195 echo "success: wbinfo -Y check for sane mapping"
198 testfail "wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed=`expr $failed + 1`
200 testit "wbinfo -t against $TARGET" $wbinfo -t || failed=`expr $failed + 1`
202 #didn't really work anyway
203 testit "wbinfo --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
204 testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
206 testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1`
208 echo "test: wbinfo --own-domain against $TARGET check output"
209 own_domain=`$wbinfo --own-domain`
210 if test x$own_domain = x$DOMAIN; then
211 echo "success: wbinfo --own-domain against $TARGET check output"
213 echo "Own domain reported as $own_domain instead of $DOMAIN"
214 echo "failure: wbinfo --own-domain against $TARGET check output"
215 failed=`expr $failed + 1`
219 knownfail "wbinfo --sequence against $TARGET" $wbinfo --sequence
221 # this is stubbed out now
222 testit "wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed=`expr $failed + 1`
224 testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
226 echo "test: wbinfo --group-info against $TARGET"
227 gid=`$wbinfo --group-info "$DOMAIN/Domain users" | cut -d: -f3`
228 if test x$? = x0; then
229 echo "success: wbinfo --group-info against $TARGET"
231 echo "failure: wbinfo --group-info against $TARGET"
232 failed=`expr $failed + 1`
235 test_name="wbinfo -i against $TARGET"
236 subunit_start_test "$test_name"
237 passwd_line=`$wbinfo -i "$DOMAIN/$USERNAME"`
238 if test x$? = x0; then
239 subunit_pass_test "$test_name"
241 subunit_fail_test "$test_name"
242 failed=`expr $failed + 1`
245 test_name="confirm output of wbinfo -i against $TARGET"
246 subunit_start_test "$test_name"
248 # The full name (GECOS) is based on name (the RDN, in this case CN)
249 # and displayName in winbindd_ads, and is based only on displayName in
250 # winbindd_msrpc and winbindd_rpc. Allow both versions.
251 if test "$TARGET" = "ad_member"; then
252 expected1_line="$DOMAIN/administrator:*:$admin_uid:$gid:Administrator:/home/$DOMAIN/Domain Users/administrator:/bin/false"
253 expected2_line="$DOMAIN/administrator:*:$admin_uid:$gid::/home/$DOMAIN/Domain Users/administrator:/bin/false"
255 expected1_line="$DOMAIN/administrator:*:$admin_uid:$gid:Administrator:/home/$DOMAIN/administrator:/bin/false"
256 expected2_line="$DOMAIN/administrator:*:$admin_uid:$gid::/home/$DOMAIN/administrator:/bin/false"
259 if test "x$passwd_line" = "x$expected1_line" -o "x$passwd_line" = "x$expected2_line"; then
260 subunit_pass_test "$test_name"
262 echo "expected '$expected1_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
263 failed=`expr $failed + 1`
266 test_name="wbinfo --uid-info against $TARGET"
267 subunit_start_test "$test_name"
268 passwd_line=`$wbinfo --uid-info=$admin_uid`
269 if test x$? = x0; then
270 subunit_pass_test "$test_name"
272 subunit_fail_test "$test_name"
273 failed=`expr $failed + 1`
276 test_name="confirm output of wbinfo --uid-info against $TARGET"
277 subunit_start_test "$test_name"
278 if test "x$passwd_line" = "x$expected1_line" -o "x$passwd_line" = "x$expected2_line"; then
279 subunit_pass_test "$test_name"
281 echo "expected '$expected1_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
282 failed=`expr $failed + 1`
285 testfail "wbinfo --group-info against $TARGET with $USERNAME" $wbinfo --group-info $USERNAME && failed=`expr $failed + 1`
287 testit "wbinfo --gid-info against $TARGET" $wbinfo --gid-info $gid || failed=`expr $failed + 1`
289 testit "wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
291 testit "wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed=`expr $failed + 1`
293 testit "wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed=`expr $failed + 1`
295 testit "wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
297 testit "wbinfo --getdcname against $TARGET" $wbinfo --getdcname=$DOMAIN
299 testit "wbinfo -p against $TARGET" $wbinfo -p || failed=`expr $failed + 1`
301 testit "wbinfo -K against $TARGET with domain creds" $wbinfo --krb5ccname=$KRB5CCNAME --krb5auth="$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
303 testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=`expr $failed + 1`
305 if test "$TARGET" = "ad_member"; then
306 testit "wbinfo --domain-info=$DOMAIN" $wbinfo --domain-info=$DOMAIN || failed=`expr $failed + 1`
308 testit "wbinfo --dc-info=$DOMAIN" $wbinfo --dc-info=$DOMAIN || failed=`expr $failed + 1`
311 testit_expect_failure "wbinfo -a against $TARGET with invalid password" $wbinfo -a "$DOMAIN/$USERNAME%InvalidPassword" && failed=`expr $failed + 1`
313 testit_expect_failure "wbinfo -K against $TARGET with invalid password" $wbinfo -K "$DOMAIN/$USERNAME%InvalidPassword" && failed=`expr $failed + 1`
315 rm -f $KRB5CCNAME_PATH