]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
test: test site-aware DC lookup via "net lookup ldap"
authorVolker Lendecke <vl@samba.org>
Fri, 4 Dec 2020 19:00:28 +0000 (20:00 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 11 Dec 2020 18:29:32 +0000 (18:29 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/script/tests/test_net_lookup.sh [new file with mode: 0755]
source3/selftest/tests.py

diff --git a/source3/script/tests/test_net_lookup.sh b/source3/script/tests/test_net_lookup.sh
new file mode 100755 (executable)
index 0000000..c2e032c
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+if [ $# != 6 ] ; then
+    echo "Usage: $0 SERVER USERNAME PASSWORD NET SAMBA-TOOL DNS-ZONE"
+    exit 1
+fi
+
+SERVER="$1"; shift 1
+USERNAME="$1"; shift 1
+PASSWORD="$1"; shift 1
+NET="$1"; shift 1
+SAMBATOOL="$1"; shift 1
+DNSZONE="$1"; shift 1
+
+SITE="mysite"
+
+incdir=$(dirname $0)/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+$SAMBATOOL dns add "$SERVER" -U "$USERNAME"%"$PASSWORD" \
+          _msdcs."$DNSZONE" _ldap._tcp."$SITE"._sites.dc \
+          SRV "mydc.$DNSZONE 389 100 100"
+$SAMBATOOL dns add "$SERVER" -U "$USERNAME"%"$PASSWORD" \
+          "$DNSZONE" mydc \
+          A "1.2.3.4"
+
+# global lookup
+testit_grep global 10.53.57.30:389 $NET lookup ldap "$DNSZONE" ||
+    failed = `expr $failed + 1`
+
+# correct site-aware lookup
+testit_grep site-aware 1.2.3.4:389 $NET lookup ldap "$DNSZONE" "$SITE" ||
+    failed = `expr $failed + 1`
+
+# lookup with nonexisting site -- global fallback
+testit_grep global 10.53.57.30:389 $NET lookup ldap "$DNSZONE" nosite ||
+    failed = `expr $failed + 1`
+
+$SAMBATOOL dns delete "$SERVER" -U "$USERNAME"%"$PASSWORD" \
+          "$DNSZONE" mydc \
+          A "1.2.3.4"
+$SAMBATOOL dns delete "$SERVER" -U "$USERNAME"%"$PASSWORD" \
+          _msdcs."$DNSZONE" _ldap._tcp."$SITE"._sites.dc \
+          SRV "mydc.$DNSZONE 389 100 100"
+
+testok $0 $failed
index 9b13ceaa4ab112f1ad46a05f3f76a3b87d5b1a49..dd6f2a9010abe1253d12b19789804a5bba76a4ce 100755 (executable)
@@ -1151,6 +1151,18 @@ plantestsuite(
      "",
      "-b $PREFIX/clusteredmember/unclists/tmp.txt -N 5 -o 10"])
 
+plantestsuite(
+    "samba3.net_lookup_ldap",
+    "ad_dc:local",
+    [os.path.join(samba3srcdir,
+                  "script/tests/test_net_lookup.sh"),
+     '$DC_SERVER',
+     '$DC_USERNAME',
+     '$DC_PASSWORD',
+     "bin/net",
+     "bin/samba-tool",
+     '$DNSNAME'])
+
 def planclusteredmembertestsuite(tname, prefix):
     '''Define a clustered test for the clusteredmember environment'''