From: Volker Lendecke Date: Fri, 4 Dec 2020 19:00:28 +0000 (+0100) Subject: test: test site-aware DC lookup via "net lookup ldap" X-Git-Tag: samba-4.14.0rc1~438 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9fa3ce29d6b6280bb2c3ec6e3e30bbb65dbe6f57;p=thirdparty%2Fsamba.git test: test site-aware DC lookup via "net lookup ldap" Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- 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'''