summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-12-04 20:00:28 +0100
committerJeremy Allison <jra@samba.org>2020-12-11 18:29:32 +0000
commit9fa3ce29d6b6280bb2c3ec6e3e30bbb65dbe6f57 (patch)
tree9491025769b148cfe46a8ef537f583862cb2c727 /source3
parentb324e2e1a151f31d8b18298f25098eb77fe18610 (diff)
downloadsamba-9fa3ce29d6b6280bb2c3ec6e3e30bbb65dbe6f57.tar.gz
samba-9fa3ce29d6b6280bb2c3ec6e3e30bbb65dbe6f57.tar.bz2
samba-9fa3ce29d6b6280bb2c3ec6e3e30bbb65dbe6f57.zip
test: test site-aware DC lookup via "net lookup ldap"
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rwxr-xr-xsource3/script/tests/test_net_lookup.sh48
-rwxr-xr-xsource3/selftest/tests.py12
2 files changed, 60 insertions, 0 deletions
diff --git a/source3/script/tests/test_net_lookup.sh b/source3/script/tests/test_net_lookup.sh
new file mode 100755
index 00000000000..c2e032ca827
--- /dev/null
+++ b/source3/script/tests/test_net_lookup.sh
@@ -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
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 9b13ceaa4ab..dd6f2a9010a 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -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'''