libnet: Fix Coverity ID 1634803 Dereference after null check
[samba4-gss.git] / source3 / script / tests / test_net_lookup.sh
blobee183335550dfb227489fe749bc486dafcdea362
1 #!/bin/sh
3 if [ $# != 6 ]; then
4 echo "Usage: $0 SERVER USERNAME PASSWORD NET SAMBA-TOOL DNS-ZONE"
5 exit 1
6 fi
8 SERVER="$1"
9 shift 1
10 USERNAME="$1"
11 shift 1
12 PASSWORD="$1"
13 shift 1
14 NET="$1"
15 shift 1
16 SAMBATOOL="$1"
17 shift 1
18 DNSZONE="$1"
19 shift 1
21 SITE="mysite"
23 incdir=$(dirname $0)/../../../testprogs/blackbox
24 . $incdir/subunit.sh
26 failed=0
28 $SAMBATOOL dns add "$SERVER" -U "$USERNAME"%"$PASSWORD" \
29 _msdcs."$DNSZONE" _ldap._tcp."$SITE"._sites.dc \
30 SRV "mydc.$DNSZONE 389 100 100"
31 $SAMBATOOL dns add "$SERVER" -U "$USERNAME"%"$PASSWORD" \
32 "$DNSZONE" mydc \
33 A "1.2.3.4"
35 # global lookup
36 testit_grep global 10.53.57.30:389 $NET lookup ldap "$DNSZONE" ||
37 failed=$(expr $failed + 1)
39 # correct site-aware lookup
40 testit_grep site-aware 1.2.3.4:389 $NET lookup ldap "$DNSZONE" "$SITE" ||
41 failed=$(expr $failed + 1)
43 # lookup with nonexisting site -- global fallback
44 testit_grep global 10.53.57.30:389 $NET lookup ldap "$DNSZONE" nosite ||
45 failed=$(expr $failed + 1)
47 $SAMBATOOL dns delete "$SERVER" -U "$USERNAME"%"$PASSWORD" \
48 "$DNSZONE" mydc \
49 A "1.2.3.4"
50 $SAMBATOOL dns delete "$SERVER" -U "$USERNAME"%"$PASSWORD" \
51 _msdcs."$DNSZONE" _ldap._tcp."$SITE"._sites.dc \
52 SRV "mydc.$DNSZONE 389 100 100"
54 testok $0 $failed