1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

selftest: Split out dns_hub's testenv realm-to-IP logic

Add a separate helper function, as the realm-to-IPv4-addr logic is
fairly self-contained.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Tim Beale 2019-02-14 17:36:40 +13:00 committed by Andrew Bartlett
parent 90ea8c2a99
commit d6d8ecb596

View File

@ -69,20 +69,8 @@ class DnsHandler(sserver.BaseRequestHandler):
s.close()
return None
def forwarder(self, name):
lname = name.lower()
if lname.endswith('an-address-that-will-not-resolve'):
return 'ignore'
if lname.endswith('dsfsdfs'):
return 'fail'
if lname.endswith("torture1", 0, len(lname)-2):
# CATCH TORTURE100, TORTURE101, ...
return 'torture'
if lname.endswith('_none_.example.com'):
return 'torture'
if lname.endswith('torturedom.samba.example.com'):
return 'torture'
def get_pdc_ipv4_addr(self, lookup_name):
"""Maps a DNS realm to the IPv4 address of the PDC for that testenv"""
# this maps the SOCKET_WRAPPER_DEFAULT_IFACE value (which is the
# last byte of the IP address) for the various testenv PDCs to the
@ -108,12 +96,31 @@ class DnsHandler(sserver.BaseRequestHandler):
testenv_realms.reverse()
for realm in testenv_realms:
if lname.endswith(realm):
if lookup_name.endswith(realm):
iface = testenv_iface_mapping[realm]
return '127.0.0.' + str(iface)
return None
def forwarder(self, name):
lname = name.lower()
# check for special cases used by tests (e.g. dns_forwarder.py)
if lname.endswith('an-address-that-will-not-resolve'):
return 'ignore'
if lname.endswith('dsfsdfs'):
return 'fail'
if lname.endswith("torture1", 0, len(lname)-2):
# CATCH TORTURE100, TORTURE101, ...
return 'torture'
if lname.endswith('_none_.example.com'):
return 'torture'
if lname.endswith('torturedom.samba.example.com'):
return 'torture'
# return the testenv PDC matching the realm being requested
return self.get_pdc_ipv4_addr(lname)
def handle(self):
start = time.monotonic()
data, sock = self.request