tests: Make IPv4 assumption explicit
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 12 Mar 2019 21:18:41 +0000 (10:18 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 14 Mar 2019 02:12:19 +0000 (02:12 +0000)
This test is asserting the expected number of *IPv4* addresses, not any
interface address (including IPv6). It works currently because the
selftest client doesn't have an IPv6 address in its smb.conf.

This patch makes the IPv4 assumption explicit by importing
interface_ips_v4() from the provision code. We need to tweak this to
pass through an 'all_interfaces' flag, otherwise it filters out the
loopback IP addresses that the testenv is using.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/provision/__init__.py
python/samba/tests/join.py

index 1b7762eb12b17113b8f04152c1c2d01fc2a2f452..0a3a7b89cb7ae4a553bd831a5a73148c36f3b237 100644 (file)
@@ -1853,9 +1853,9 @@ def checksysvolacl(samdb, netlogon, sysvol, domainsid, dnsdomain, domaindn,
                        direct_db_access)
 
 
-def interface_ips_v4(lp):
+def interface_ips_v4(lp, all_interfaces=False):
     """return only IPv4 IPs"""
-    ips = samba.interface_ips(lp, False)
+    ips = samba.interface_ips(lp, all_interfaces)
     ret = []
     for i in ips:
         if i.find(':') == -1:
index 09a102e26af9963fe557bdf57c1e0614f830b87d..e0ad34e1e74b57156e861c0c8107319a044772c4 100644 (file)
@@ -24,6 +24,7 @@ from samba.tests.dns_base import DNSTKeyTest
 from samba.join import DCJoinContext
 from samba.dcerpc import drsuapi, misc, dns
 from samba.credentials import Credentials
+from samba.provision import interface_ips_v4
 
 
 def get_logger(name="subunit"):
@@ -92,7 +93,7 @@ class JoinTestCase(DNSTKeyTest):
         questions.append(q)
 
         # Get expected IPs
-        IPs = samba.interface_ips(self.lp)
+        IPs = interface_ips_v4(self.lp, all_interfaces=True)
 
         self.finish_name_packet(p, questions)
         (response, response_packet) = self.dns_transaction_tcp(p, host=self.server_ip)
@@ -132,7 +133,7 @@ class JoinTestCase(DNSTKeyTest):
 
         updates = []
         # Delete the old expected IPs
-        IPs = samba.interface_ips(self.lp)
+        IPs = interface_ips_v4(self.lp, all_interfaces=True)
         for IP in IPs[1:]:
             if ":" in IP:
                 r = dns.res_rec()