| 1 | #!/bin/sh
|
|---|
| 2 | # Blackbox test for wbinfo
|
|---|
| 3 | if [ $# -lt 4 ]; then
|
|---|
| 4 | cat <<EOF
|
|---|
| 5 | Usage: test_wbinfo.sh DOMAIN USERNAME PASSWORD TARGET
|
|---|
| 6 | EOF
|
|---|
| 7 | exit 1;
|
|---|
| 8 | fi
|
|---|
| 9 |
|
|---|
| 10 | DOMAIN=$1
|
|---|
| 11 | USERNAME=$2
|
|---|
| 12 | PASSWORD=$3
|
|---|
| 13 | TARGET=$4
|
|---|
| 14 | shift 4
|
|---|
| 15 |
|
|---|
| 16 | failed=0
|
|---|
| 17 | samba4bindir="$BINDIR"
|
|---|
| 18 | wbinfo="$VALGRIND $samba4bindir/wbinfo"
|
|---|
| 19 |
|
|---|
| 20 | . `dirname $0`/../../testprogs/blackbox/subunit.sh
|
|---|
| 21 |
|
|---|
| 22 | testfail() {
|
|---|
| 23 | name="$1"
|
|---|
| 24 | shift
|
|---|
| 25 | cmdline="$*"
|
|---|
| 26 | echo "test: $name"
|
|---|
| 27 | $cmdline
|
|---|
| 28 | status=$?
|
|---|
| 29 | if [ x$status = x0 ]; then
|
|---|
| 30 | echo "failure: $name"
|
|---|
| 31 | else
|
|---|
| 32 | echo "success: $name"
|
|---|
| 33 | fi
|
|---|
| 34 | return $status
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | knownfail() {
|
|---|
| 38 | name="$1"
|
|---|
| 39 | shift
|
|---|
| 40 | cmdline="$*"
|
|---|
| 41 | echo "test: $name"
|
|---|
| 42 | $cmdline
|
|---|
| 43 | status=$?
|
|---|
| 44 | if [ x$status = x0 ]; then
|
|---|
| 45 | echo "failure: $name [unexpected success]"
|
|---|
| 46 | status=1
|
|---|
| 47 | else
|
|---|
| 48 | echo "knownfail: $name"
|
|---|
| 49 | status=0
|
|---|
| 50 | fi
|
|---|
| 51 | return $status
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | # List users
|
|---|
| 55 | testit "wbinfo -u against $TARGET" $wbinfo -u || failed=`expr $failed + 1`
|
|---|
| 56 | # List groups
|
|---|
| 57 | testit "wbinfo -g against $TARGET" $wbinfo -g || failed=`expr $failed + 1`
|
|---|
| 58 | # Convert netbios name to IP
|
|---|
| 59 | # Does not work yet
|
|---|
| 60 | testit "wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed=`expr $failed + 1`
|
|---|
| 61 | # Convert IP to netbios name
|
|---|
| 62 | # Does not work yet
|
|---|
| 63 | testit "wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed=`expr $failed + 1`
|
|---|
| 64 |
|
|---|
| 65 | # Convert name to SID
|
|---|
| 66 | testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
|
|---|
| 67 | admin_sid=`$wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1`
|
|---|
| 68 | echo "$DOMAIN/$USERNAME resolved to $admin_sid"
|
|---|
| 69 |
|
|---|
| 70 | testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=`expr $failed + 1`
|
|---|
| 71 | admin_name=`$wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z`
|
|---|
| 72 | echo "$admin_sid resolved to $admin_name"
|
|---|
| 73 |
|
|---|
| 74 | tested_name=`echo $DOMAIN/$USERNAME | tr a-z A-Z`
|
|---|
| 75 |
|
|---|
| 76 | echo "test: wbinfo -s check for sane mapping"
|
|---|
| 77 | if test x$admin_name != x$tested_name; then
|
|---|
| 78 | echo "$admin_name does not match $tested_name"
|
|---|
| 79 | echo "failure: wbinfo -s check for sane mapping"
|
|---|
| 80 | failed=`expr $failed + 1`
|
|---|
| 81 | else
|
|---|
| 82 | echo "success: wbinfo -s check for sane mapping"
|
|---|
| 83 | fi
|
|---|
| 84 |
|
|---|
| 85 | testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed=`expr $failed + 1`
|
|---|
| 86 | test_sid=`$wbinfo -n $tested_name | cut -d " " -f1`
|
|---|
| 87 |
|
|---|
| 88 | echo "test: wbinfo -n check for sane mapping"
|
|---|
| 89 | if test x$admin_sid != x$test_sid; then
|
|---|
| 90 | echo "$admin_sid does not match $test_sid"
|
|---|
| 91 | echo "failure: wbinfo -n check for sane mapping"
|
|---|
| 92 | failed=`expr $failed + 1`
|
|---|
| 93 | else
|
|---|
| 94 | echo "success: wbinfo -n check for sane mapping"
|
|---|
| 95 | fi
|
|---|
| 96 |
|
|---|
| 97 | testit "wbinfo -U against $TARGET" $wbinfo -U 30000 || failed=`expr $failed + 1`
|
|---|
| 98 |
|
|---|
| 99 | echo "test: wbinfo -U check for sane mapping"
|
|---|
| 100 | sid_for_30000=`$wbinfo -U 30000`
|
|---|
| 101 | if test x$sid_for_30000 != "xS-1-22-1-30000"; then
|
|---|
| 102 | echo "uid 30000 mapped to $sid_for_30000, not S-1-22-1-30000"
|
|---|
| 103 | echo "failure: wbinfo -U check for sane mapping"
|
|---|
| 104 | failed=`expr $failed + 1`
|
|---|
| 105 | else
|
|---|
| 106 | echo "success: wbinfo -U check for sane mapping"
|
|---|
| 107 | fi
|
|---|
| 108 |
|
|---|
| 109 | admin_uid=`$wbinfo -S $admin_sid`
|
|---|
| 110 |
|
|---|
| 111 | testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=`expr $failed + 1`
|
|---|
| 112 |
|
|---|
| 113 | echo "test: wbinfo -G check for sane mapping"
|
|---|
| 114 | sid_for_30000=`$wbinfo -G 30000`
|
|---|
| 115 | if test x$sid_for_30000 != "xS-1-22-2-30000"; then
|
|---|
| 116 | echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
|
|---|
| 117 | echo "failure: wbinfo -G check for sane mapping"
|
|---|
| 118 | failed=`expr $failed + 1`
|
|---|
| 119 | else
|
|---|
| 120 | echo "success: wbinfo -G check for sane mapping"
|
|---|
| 121 | fi
|
|---|
| 122 |
|
|---|
| 123 | testit "wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed=`expr $failed + 1`
|
|---|
| 124 |
|
|---|
| 125 | echo "test: wbinfo -S check for sane mapping"
|
|---|
| 126 | uid_for_sid=`$wbinfo -S S-1-22-1-30000`
|
|---|
| 127 | if test 0$uid_for_sid -ne 30000; then
|
|---|
| 128 | echo "S-1-22-1-30000 mapped to $uid_for_sid, not 30000"
|
|---|
| 129 | echo "failure: wbinfo -S check for sane mapping"
|
|---|
| 130 | failed=`expr $failed + 1`
|
|---|
| 131 | else
|
|---|
| 132 | echo "success: wbinfo -S check for sane mapping"
|
|---|
| 133 | fi
|
|---|
| 134 |
|
|---|
| 135 | testfail "wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed=`expr $failed + 1`
|
|---|
| 136 |
|
|---|
| 137 | testit "wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed=`expr $failed + 1`
|
|---|
| 138 |
|
|---|
| 139 | echo "test: wbinfo -Y check for sane mapping"
|
|---|
| 140 | gid_for_sid=`$wbinfo -Y S-1-22-2-30000`
|
|---|
| 141 | if test 0$gid_for_sid -ne 30000; then
|
|---|
| 142 | echo "S-1-22-2-30000 mapped to $gid_for_sid, not 30000"
|
|---|
| 143 | echo "failure: wbinfo -Y check for sane mapping"
|
|---|
| 144 | failed=`expr $failed + 1`
|
|---|
| 145 | else
|
|---|
| 146 | echo "success: wbinfo -Y check for sane mapping"
|
|---|
| 147 | fi
|
|---|
| 148 |
|
|---|
| 149 | testfail "wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed=`expr $failed + 1`
|
|---|
| 150 |
|
|---|
| 151 | testit "wbinfo -t against $TARGET" $wbinfo -t || failed=`expr $failed + 1`
|
|---|
| 152 |
|
|---|
| 153 | #didn't really work anyway
|
|---|
| 154 | testit "wbinfo --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
|
|---|
| 155 | testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
|
|---|
| 156 |
|
|---|
| 157 | testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1`
|
|---|
| 158 |
|
|---|
| 159 | echo "test: wbinfo --own-domain against $TARGET check output"
|
|---|
| 160 | own_domain=`$wbinfo --own-domain`
|
|---|
| 161 | if test x$own_domain = x$DOMAIN; then
|
|---|
| 162 | echo "success: wbinfo --own-domain against $TARGET check output"
|
|---|
| 163 | else
|
|---|
| 164 | echo "Own domain reported as $own_domain instead of $DOMAIN"
|
|---|
| 165 | echo "failure: wbinfo --own-domain against $TARGET check output"
|
|---|
| 166 | failed=`expr $failed + 1`
|
|---|
| 167 | fi
|
|---|
| 168 |
|
|---|
| 169 | # this does not work
|
|---|
| 170 | knownfail "wbinfo --sequence against $TARGET" $wbinfo --sequence
|
|---|
| 171 |
|
|---|
| 172 | # this is stubbed out now
|
|---|
| 173 | testit "wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed=`expr $failed + 1`
|
|---|
| 174 |
|
|---|
| 175 | testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
|
|---|
| 176 |
|
|---|
| 177 | echo "test: wbinfo --group-info against $TARGET"
|
|---|
| 178 | gid=`$wbinfo --group-info "$DOMAIN/Domain users" | cut -d: -f3`
|
|---|
| 179 | if test x$? = x0; then
|
|---|
| 180 | echo "success: wbinfo --group-info against $TARGET"
|
|---|
| 181 | else
|
|---|
| 182 | echo "failure: wbinfo --group-info against $TARGET"
|
|---|
| 183 | failed=`expr $failed + 1`
|
|---|
| 184 | fi
|
|---|
| 185 |
|
|---|
| 186 | test_name="wbinfo -i against $TARGET"
|
|---|
| 187 | subunit_start_test "$test_name"
|
|---|
| 188 | passwd_line=`$wbinfo -i "$DOMAIN/$USERNAME"`
|
|---|
| 189 | if test x$? = x0; then
|
|---|
| 190 | subunit_pass_test "$test_name"
|
|---|
| 191 | else
|
|---|
| 192 | subunit_fail_test "$test_name"
|
|---|
| 193 | failed=`expr $failed + 1`
|
|---|
| 194 | fi
|
|---|
| 195 |
|
|---|
| 196 | test_name="confirm output of wbinfo -i against $TARGET"
|
|---|
| 197 | subunit_start_test "$test_name"
|
|---|
| 198 |
|
|---|
| 199 | # The full name (GECOS) is based on name (the RDN, in this case CN)
|
|---|
| 200 | # and displayName in winbindd_ads, and is based only on displayName in
|
|---|
| 201 | # winbindd_msrpc and winbindd_rpc. Allow both versions.
|
|---|
| 202 | expected_line="$DOMAIN/administrator:*:$admin_uid:$gid:Administrator:/home/$DOMAIN/administrator:/bin/false"
|
|---|
| 203 | expected2_line="$DOMAIN/administrator:*:$admin_uid:$gid::/home/$DOMAIN/administrator:/bin/false"
|
|---|
| 204 |
|
|---|
| 205 | if test x$passwd_line = x"$expected_line" -o x$passwd_line = x"$expected2_line"; then
|
|---|
| 206 | subunit_pass_test "$test_name"
|
|---|
| 207 | else
|
|---|
| 208 | echo "expected '$expected_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
|
|---|
| 209 | failed=`expr $failed + 1`
|
|---|
| 210 | fi
|
|---|
| 211 |
|
|---|
| 212 | test_name="wbinfo --uid-info against $TARGET"
|
|---|
| 213 | subunit_start_test "$test_name"
|
|---|
| 214 | passwd_line=`$wbinfo --uid-info=$admin_uid`
|
|---|
| 215 | if test x$? = x0; then
|
|---|
| 216 | subunit_pass_test "$test_name"
|
|---|
| 217 | else
|
|---|
| 218 | subunit_fail_test "$test_name"
|
|---|
| 219 | failed=`expr $failed + 1`
|
|---|
| 220 | fi
|
|---|
| 221 |
|
|---|
| 222 | test_name="confirm output of wbinfo --uid-info against $TARGET"
|
|---|
| 223 | subunit_start_test "$test_name"
|
|---|
| 224 | if test x$passwd_line = x"$expected_line" -o x$passwd_line = x"$expected2_line"; then
|
|---|
| 225 | subunit_pass_test "$test_name"
|
|---|
| 226 | else
|
|---|
| 227 | echo "expected '$expected_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
|
|---|
| 228 | failed=`expr $failed + 1`
|
|---|
| 229 | fi
|
|---|
| 230 |
|
|---|
| 231 | testfail "wbinfo --group-info against $TARGET with $USERNAME" $wbinfo --group-info $USERNAME && failed=`expr $failed + 1`
|
|---|
| 232 |
|
|---|
| 233 | testit "wbinfo --gid-info against $TARGET" $wbinfo --gid-info $gid || failed=`expr $failed + 1`
|
|---|
| 234 |
|
|---|
| 235 | testit "wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
|
|---|
| 236 |
|
|---|
| 237 | testit "wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed=`expr $failed + 1`
|
|---|
| 238 |
|
|---|
| 239 | testit "wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed=`expr $failed + 1`
|
|---|
| 240 |
|
|---|
| 241 | testit "wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
|
|---|
| 242 |
|
|---|
| 243 | testit "wbinfo --getdcname against $TARGET" $wbinfo --getdcname=$DOMAIN
|
|---|
| 244 |
|
|---|
| 245 | testit "wbinfo -p against $TARGET" $wbinfo -p || failed=`expr $failed + 1`
|
|---|
| 246 |
|
|---|
| 247 | testit "wbinfo -K against $TARGET with domain creds" $wbinfo -K "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
|
|---|
| 248 |
|
|---|
| 249 | testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=`expr $failed + 1`
|
|---|
| 250 |
|
|---|
| 251 | exit $failed
|
|---|