summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAaron Haslett <aaronhaslett@catalyst.net.nz>2018-07-10 13:23:42 +1200
committerAndrew Bartlett <abartlet@samba.org>2018-07-12 04:31:55 +0200
commit6bd2f82b9ff7629effe8280ab8f6bf9d721cf767 (patch)
treeb67ef76a0b8386c805c854f2f5e74454a0cac76f /python
parent00002b8df9b865b896d264ee22bf6f22cf935f56 (diff)
downloadsamba-6bd2f82b9ff7629effe8280ab8f6bf9d721cf767.tar.gz
dns: Use ldb.SCOPE_SUBTREE in ldap_get_records() routine in tests/dns.py
DNS records have the odd property that the DN can be reliably determined by the name only, so we do not need a subtree search. However by using a subtree search under the zone we can without trapping exceptions confirm if the record exists or not in the tests. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10812 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/dns.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py
index 52505560e1c..c0f71dbf633 100644
--- a/python/samba/tests/dns.py
+++ b/python/samba/tests/dns.py
@@ -969,9 +969,11 @@ class TestZones(DNSTest):
return recs[0]
def ldap_get_records(self, name):
- dn = 'DC={},{}'.format(name, self.zone_dn)
+ # The use of SCOPE_SUBTREE here avoids raising an exception in the
+ # 0 results case for a test below.
+
expr = "(&(objectClass=dnsNode)(name={}))".format(name)
- return self.samdb.search(base=dn, scope=ldb.SCOPE_SUBTREE,
+ return self.samdb.search(base=self.zone_dn, scope=ldb.SCOPE_SUBTREE,
expression=expr, attrs=["*"])
def ldap_get_dns_records(self, name):