Debian Codegraph @

nsswitch/tests/test_wbinfo_name_lookup.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Blackbox test for wbinfo name lookup
3 if [scip-shell system . . `[`. $# -lt 3 ]; then
4 catscip-shell system . . cat. <<EOF
5 Usage: test_wbinfo_name_lookup.sh DOMAIN REALM DC_USERNAME
6 EOF
7 exit 1
8 fi
9
10 DOMAIN=$1
11 REALM=$2
12 DC_USERNAME=$3
13 shift 3
14
15 failed=0
16 sambabindir="$BINDIR"
17 wbinfo="$VALGRIND $sambabindir/wbinfo"
18
19 . $(dirnamescip-shell system . . dirname. $0)/../../testprogs/blackbox/subunit.sh
20
21 # Correct query is expected to work
22 testit "name-to-sid.single-separator" \
23 $wbinfo -n $DOMAIN/$DC_USERNAME ||
24 failed=$(exprscip-shell system . . expr. $failed + 1)
25
26 testit "name-to-sid.at_domain" \
27 $wbinfo -n $DOMAIN/ ||
28 failed=$(exprscip-shell system . . expr. $failed + 1)
29
30 testit "name-to-sid.upn" \
31 $wbinfo -n $DC_USERNAME@$REALM ||
32 failed=$(exprscip-shell system . . expr. $failed + 1)
33
34 testit "name-to-sid.realm-user" \
35 $wbinfo -n $REALM/$DC_USERNAME ||
36 failed=$(exprscip-shell system . . expr. $failed + 1)
37
38 # For the name-to-sid.realm-user query, ensure
39 # that this does not change subsequent sid-to-name
40 # queries.
41 sid=$($wbinfo -n $REALM/$DC_USERNAME | sedscip-shell system . . sed. -e 's/ .*//')
42 out=$($wbinfo -s $sid | sedscip-shell system . . sed. -e 's/ .//')
43 # winbindd returns usernames in lowercase
44 lcuser=$(echoscip-shell system . . echo. $DC_USERNAME | trscip-shell system . . tr. A-Z a-z)
45 testit "Verify DOMAIN/USER output" \
46 test "$out" = "$DOMAIN/$lcuser" ||
47 failed=$(exprscip-shell system . . expr. $failed + 1)
48
49 # Two separator characters should fail
50 testit_expect_failure "name-to-sid.double-separator" \
51 $wbinfo -n $DOMAIN//$DC_USERNAME ||
52 failed=$(exprscip-shell system . . expr. $failed + 1)
53
54 # Invalid domain is expected to fail
55 testit_expect_failure "name-to-sid.invalid-domain" \
56 $wbinfo -n INVALID/$DC_USERNAME ||
57 failed=$(exprscip-shell system . . expr. $failed + 1)
58
59 # Invalid domain with two separator characters is expected to fail
60 testit_expect_failure "name-to-sid.double-separator-invalid-domain" \
61 $wbinfo -n INVALID//$DC_USERNAME ||
62 failed=$(exprscip-shell system . . expr. $failed + 1)
63
64 exit $failed