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
30 if [ x
$status = x0
]; then
46 if [ x
$status = x0
]; then
47 echo "failure: $name [unexpected success]"
50 echo "knownfail: $name"
56 KRB5CCNAME_PATH
="$PREFIX/test_wbinfo_krb5ccache"
57 rm -f $KRB5CCNAME_PATH
59 KRB5CCNAME
="FILE:$KRB5CCNAME_PATH"
63 testit
"wbinfo -u against $TARGET" $wbinfo -u || failed
=$
(expr $failed + 1)
65 testit
"wbinfo -g against $TARGET" $wbinfo -g || failed
=$
(expr $failed + 1)
66 # Convert netbios name to IP
68 testit
"wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed
=$
(expr $failed + 1)
69 # Convert IP to netbios name
71 testit
"wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed
=$
(expr $failed + 1)
74 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed
=$
(expr $failed + 1)
75 admin_sid
=$
($wbinfo -n "$DOMAIN/$USERNAME" | cut
-d " " -f1)
76 echo "$DOMAIN/$USERNAME resolved to $admin_sid"
78 testit
"wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed
=$
(expr $failed + 1)
79 admin_name
=$
($wbinfo -s $admin_sid | cut
-d " " -f1 |
tr a-z A-Z
)
80 echo "$admin_sid resolved to $admin_name"
82 tested_name
=$
(echo $DOMAIN/$USERNAME |
tr a-z A-Z
)
84 echo "test: wbinfo -s check for sane mapping"
85 if test x
$admin_name != x
$tested_name; then
86 echo "$admin_name does not match $tested_name"
87 echo "failure: wbinfo -s check for sane mapping"
88 failed
=$
(expr $failed + 1)
90 echo "success: wbinfo -s check for sane mapping"
96 testit
"wbinfo -s $SID against $TARGET" $wbinfo -s $SID || failed
=$
(expr $failed + 1)
98 RESOLVED_NAME
=$
($wbinfo -s $SID |
tr a-z A-Z
)
99 echo "$SID resolved to $RESOLVED_NAME"
101 echo "test: wbinfo -s $SID against $TARGET"
102 if test x
"$RESOLVED_NAME" != x
"$NAME"; then
103 echo "$RESOLVED_NAME does not match $NAME"
104 echo "failure: wbinfo -s $SID against $TARGET"
105 failed
=$
(expr $failed + 1)
107 echo "success: wbinfo -s $SID against $TARGET"
115 NT AUTHORITY/DIALUP 5
118 testit
"wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed
=$
(expr $failed + 1)
119 test_sid
=$
($wbinfo -n $tested_name | cut
-d " " -f1)
121 echo "test: wbinfo -n check for sane mapping"
122 if test x
$admin_sid != x
$test_sid; then
123 echo "$admin_sid does not match $test_sid"
124 echo "failure: wbinfo -n check for sane mapping"
125 failed
=$
(expr $failed + 1)
127 echo "success: wbinfo -n check for sane mapping"
130 echo "test: wbinfo -n NT Authority/Authenticated Users"
131 $wbinfo -n "NT Authority/Authenticated Users"
132 if [ $?
-ne 0 ]; then
133 echo "failure: wbinfo -n NT Authority/Authenticated Users"
134 failed
=$
(expr $failed + 1)
136 echo "success: wbinfo -n NT Authority/Authenticated Users"
139 echo "test: wbinfo --group-info NT Authority/Authenticated Users"
140 $wbinfo --group-info "NT Authority/Authenticated Users"
141 if [ $?
-ne 0 ]; then
142 echo "failure: wbinfo --group-info NT Authority/Authenticated Users"
143 failed
=$
(expr $failed + 1)
145 echo "success: wbinfo --group-info NT Authority/Authenticated Users"
148 testit
"wbinfo -U against $TARGET" $wbinfo -U 30000 || failed
=$
(expr $failed + 1)
150 echo "test: wbinfo -U check for sane mapping"
151 sid_for_30000
=$
($wbinfo -U 30000)
152 if test x
$sid_for_30000 != "xS-1-22-1-30000"; then
153 echo "uid 30000 mapped to $sid_for_30000, not S-1-22-1-30000"
154 echo "failure: wbinfo -U check for sane mapping"
155 failed
=$
(expr $failed + 1)
157 echo "success: wbinfo -U check for sane mapping"
160 admin_uid
=$
($wbinfo -S $admin_sid)
162 testit
"wbinfo -G against $TARGET" $wbinfo -G 30000 || failed
=$
(expr $failed + 1)
164 echo "test: wbinfo -G check for sane mapping"
165 sid_for_30000
=$
($wbinfo -G 30000)
166 if test x
$sid_for_30000 != "xS-1-22-2-30000"; then
167 echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
168 echo "failure: wbinfo -G check for sane mapping"
169 failed
=$
(expr $failed + 1)
171 echo "success: wbinfo -G check for sane mapping"
174 testit
"wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed
=$
(expr $failed + 1)
176 echo "test: wbinfo -S check for sane mapping"
177 uid_for_sid
=$
($wbinfo -S S-1-22-1-30000
)
178 if test 0$uid_for_sid -ne 30000; then
179 echo "S-1-22-1-30000 mapped to $uid_for_sid, not 30000"
180 echo "failure: wbinfo -S check for sane mapping"
181 failed
=$
(expr $failed + 1)
183 echo "success: wbinfo -S check for sane mapping"
186 testfail
"wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed
=$
(expr $failed + 1)
188 testit
"wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed
=$
(expr $failed + 1)
190 echo "test: wbinfo -Y check for sane mapping"
191 gid_for_sid
=$
($wbinfo -Y S-1-22-2-30000
)
192 if test 0$gid_for_sid -ne 30000; then
193 echo "S-1-22-2-30000 mapped to $gid_for_sid, not 30000"
194 echo "failure: wbinfo -Y check for sane mapping"
195 failed
=$
(expr $failed + 1)
197 echo "success: wbinfo -Y check for sane mapping"
200 testfail
"wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed
=$
(expr $failed + 1)
202 testit
"wbinfo -t against $TARGET" $wbinfo -t || failed
=$
(expr $failed + 1)
204 #didn't really work anyway
205 testit
"wbinfo --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed
=$
(expr $failed + 1)
206 testit
"wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed
=$
(expr $failed + 1)
208 testit
"wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed
=$
(expr $failed + 1)
210 echo "test: wbinfo --own-domain against $TARGET check output"
211 own_domain
=$
($wbinfo --own-domain)
212 if test x
$own_domain = x
$DOMAIN; then
213 echo "success: wbinfo --own-domain against $TARGET check output"
215 echo "Own domain reported as $own_domain instead of $DOMAIN"
216 echo "failure: wbinfo --own-domain against $TARGET check output"
217 failed
=$
(expr $failed + 1)
221 knownfail
"wbinfo --sequence against $TARGET" $wbinfo --sequence
223 # this is stubbed out now
224 testit
"wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed
=$
(expr $failed + 1)
226 testit
"wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed
=$
(expr $failed + 1)
228 echo "test: wbinfo --group-info against $TARGET"
229 gid
=$
($wbinfo --group-info "$DOMAIN/Domain users" | cut
-d: -f3)
230 if test x$?
= x0
; then
231 echo "success: wbinfo --group-info against $TARGET"
233 echo "failure: wbinfo --group-info against $TARGET"
234 failed
=$
(expr $failed + 1)
237 test_name
="wbinfo -i against $TARGET"
238 subunit_start_test
"$test_name"
239 passwd_line
=$
($wbinfo -i "$DOMAIN/$USERNAME")
240 if test x$?
= x0
; then
241 subunit_pass_test
"$test_name"
243 subunit_fail_test
"$test_name"
244 failed
=$
(expr $failed + 1)
247 test_name
="confirm output of wbinfo -i against $TARGET"
248 subunit_start_test
"$test_name"
250 # The full name (GECOS) is based on name (the RDN, in this case CN)
251 # and displayName in winbindd_ads, and is based only on displayName in
252 # winbindd_msrpc and winbindd_rpc. Allow both versions.
253 if test "$TARGET" = "ad_member"; then
254 expected1_line
="$DOMAIN/administrator:*:$admin_uid:$gid:Administrator:/home/$DOMAIN/Domain Users/administrator:/bin/false"
255 expected2_line
="$DOMAIN/administrator:*:$admin_uid:$gid::/home/$DOMAIN/Domain Users/administrator:/bin/false"
257 expected1_line
="$DOMAIN/administrator:*:$admin_uid:$gid:Administrator:/home/$DOMAIN/administrator:/bin/false"
258 expected2_line
="$DOMAIN/administrator:*:$admin_uid:$gid::/home/$DOMAIN/administrator:/bin/false"
261 if test "x$passwd_line" = "x$expected1_line" -o "x$passwd_line" = "x$expected2_line"; then
262 subunit_pass_test
"$test_name"
264 echo "expected '$expected1_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test
"$test_name"
265 failed
=$
(expr $failed + 1)
268 test_name
="wbinfo --uid-info against $TARGET"
269 subunit_start_test
"$test_name"
270 passwd_line
=$
($wbinfo --uid-info=$admin_uid)
271 if test x$?
= x0
; then
272 subunit_pass_test
"$test_name"
274 subunit_fail_test
"$test_name"
275 failed
=$
(expr $failed + 1)
278 test_name
="confirm output of wbinfo --uid-info against $TARGET"
279 subunit_start_test
"$test_name"
280 if test "x$passwd_line" = "x$expected1_line" -o "x$passwd_line" = "x$expected2_line"; then
281 subunit_pass_test
"$test_name"
283 echo "expected '$expected1_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test
"$test_name"
284 failed
=$
(expr $failed + 1)
287 testfail
"wbinfo --group-info against $TARGET with $USERNAME" $wbinfo --group-info $USERNAME && failed
=$
(expr $failed + 1)
289 testit
"wbinfo --gid-info against $TARGET" $wbinfo --gid-info $gid || failed
=$
(expr $failed + 1)
291 testit
"wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME" || failed
=$
(expr $failed + 1)
293 testit
"wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed
=$
(expr $failed + 1)
295 testit
"wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed
=$
(expr $failed + 1)
297 testit
"wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed
=$
(expr $failed + 1)
299 testit
"wbinfo -a against $TARGET with domain upn creds" $wbinfo -a "$USERNAME@$DOMAIN"%"$PASSWORD" || failed
=$
(expr $failed + 1)
301 testit
"wbinfo --getdcname against $TARGET" $wbinfo --getdcname=$DOMAIN
303 testit
"wbinfo -p against $TARGET" $wbinfo -p || failed
=$
(expr $failed + 1)
305 testit
"wbinfo -K against $TARGET with domain creds" $wbinfo --krb5ccname=$KRB5CCNAME --krb5auth="$DOMAIN/$USERNAME"%"$PASSWORD" || failed
=$
(expr $failed + 1)
307 testit
"wbinfo --separator against $TARGET" $wbinfo --separator || failed
=$
(expr $failed + 1)
309 if test "$TARGET" = "ad_member"; then
310 testit
"wbinfo --domain-info=$DOMAIN" $wbinfo --domain-info=$DOMAIN || failed
=$
(expr $failed + 1)
312 testit
"wbinfo --dc-info=$DOMAIN" $wbinfo --dc-info=$DOMAIN || failed
=$
(expr $failed + 1)
315 testit_expect_failure
"wbinfo -a against $TARGET with invalid password" $wbinfo -a "$DOMAIN/$USERNAME%InvalidPassword" && failed
=$
(expr $failed + 1)
317 testit_expect_failure
"wbinfo -K against $TARGET with invalid password" $wbinfo -K "$DOMAIN/$USERNAME%InvalidPassword" && failed
=$
(expr $failed + 1)
319 rm -f $KRB5CCNAME_PATH