s4: tests: Add new async DNS unit test - samba4.blackbox.net_ads_dns_async(ad_member...
authorJeremy Allison <jra@samba.org>
Wed, 5 Aug 2020 22:46:04 +0000 (15:46 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 7 Aug 2020 06:34:36 +0000 (06:34 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/selftest/tests.py
testprogs/blackbox/test_net_ads_dns_async.sh [new file with mode: 0755]

index 6e7c014ba8d203b5e2af32055f25a1f33a0d3fce..c6da90cc740970f791057f0f03ee705aafb0e28d 100755 (executable)
@@ -544,6 +544,12 @@ plantestsuite("samba4.blackbox.client_etypes_all(ad_dc:client)", "ad_dc:client",
 plantestsuite("samba4.blackbox.client_etypes_legacy(ad_dc:client)", "ad_dc:client", [os.path.join(bbdir, "test_client_etypes.sh"), '$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD', '$PREFIX_ABS', 'legacy', '23'])
 plantestsuite("samba4.blackbox.client_etypes_strong(ad_dc:client)", "ad_dc:client", [os.path.join(bbdir, "test_client_etypes.sh"), '$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD', '$PREFIX_ABS', 'strong', '17_18'])
 plantestsuite("samba4.blackbox.net_ads_dns(ad_member:local)", "ad_member:local", [os.path.join(bbdir, "test_net_ads_dns.sh"), '$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD', '$REALM', '$USERNAME', '$PASSWORD'])
+plantestsuite("samba4.blackbox.net_ads_dns_async(ad_member:local)",
+        "ad_member:local",
+        [os.path.join(bbdir,
+            "test_net_ads_dns_async.sh"),
+            '$DC_SERVER',
+            '$REALM'])
 plantestsuite("samba4.blackbox.samba-tool_ntacl(ad_member:local)", "ad_member:local", [os.path.join(bbdir, "test_samba-tool_ntacl.sh"), '$PREFIX', '$DOMSID'])
 
 for nomech in ["none", "gse_krb5", "ntlmssp"]:
diff --git a/testprogs/blackbox/test_net_ads_dns_async.sh b/testprogs/blackbox/test_net_ads_dns_async.sh
new file mode 100755 (executable)
index 0000000..f0bd083
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Blackbox tests for net ads dns async
+# Copyright (C) 2020 Jeremy Allison <jra@samba.org>
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: test_net_ads_dns_async.sh SERVER REALM
+EOF
+exit 1;
+fi
+
+SERVER=$1
+REALM=$2
+shift 2
+failed=0
+
+samba4bindir="$BINDIR"
+net_tool="$samba4bindir/net"
+
+. `dirname $0`/subunit.sh
+
+# Test looking up SERVER.REALM on server give the
+# same IP via async and non-async DNS.
+echo "Starting ..."
+
+test_async_dns() {
+       #
+       # Do the gethostbyname request. This just prints the IPv4 addr.
+       #
+       cmd_sync='$net_tool ads dns gethostbyname $SERVER $SERVER.$REALM'
+       eval echo "$cmd_sync"
+       ipv4_sync=$(eval $cmd_sync)
+       if [ -z "$ipv4_sync" ]; then
+               return 1
+       fi
+
+       #
+       # Do the async request. This prints out info like:
+       #
+       # Async A record lookup - got 1 names for addc.ADDOM.SAMBA.EXAMPLE.COM
+       # hostname[0] = addc.ADDOM.SAMBA.EXAMPLE.COM, IPv4addr = 10.53.57.30
+       # Async AAAA record lookup - got 1 names for addc.ADDOM.SAMBA.EXAMPLE.COM
+       # hostname[0] = addc.ADDOM.SAMBA.EXAMPLE.COM, IPv6addr = fd00::5357:5f1e
+       #
+       # So we must grep and sed to extract the matching IPv4 address
+       #
+       cmd_async='$net_tool ads dns async $SERVER.$REALM'
+       eval echo "$cmd_async"
+       out_async=$(eval $cmd_async)
+
+       # Drop everything but the IPv4 address.
+       ipv4_async=`echo "$out_async" | grep IPv4addr | sed -e 's/^.*IPv4addr = //'`
+
+       if [ -z "$ipv4_async" ]; then
+               return 1
+       fi
+       if [ "$ipv4_sync" != "$ipv4_async" ]; then
+               echo "DNS lookup mismatch. Sync $ipv4_sync, async $ipv4_async"
+               echo "DNS commands output. out1=$ipv4_sync, out2=$out_async"
+               return 1
+       fi
+       return 0
+}
+
+testit "Check async and non async DNS lookups match " test_async_dns || failed=`expr $failed + 1`
+
+exit $failed