From: Aaron Haslett Date: Mon, 20 Aug 2018 04:07:15 +0000 (+1200) Subject: dns: test for treating fully qualified zones same as unqualified X-Git-Tag: tdb-1.3.17~162 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dd6175a273c7376ec6960f9a8f519fcfcf79ed37;p=thirdparty%2Fsamba.git dns: test for treating fully qualified zones same as unqualified Failing test that checks if fully qualified zone names are treated the same as unqualified zone names by the dns zone creation RPC method. Fix to follow. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13214 Signed-off-by: Aaron Haslett Reviewed-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py index 8762abf8f59..275d4fcd692 100644 --- a/python/samba/tests/dns.py +++ b/python/samba/tests/dns.py @@ -1080,7 +1080,7 @@ class TestZones(DNSTest): if num != werror.WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST: raise - def create_zone(self, zone, aging_enabled=False): + def make_zone_obj(self, zone, aging_enabled=False): zone_create = dnsserver.DNS_RPC_ZONE_CREATE_INFO_LONGHORN() zone_create.pszZoneName = zone zone_create.dwZoneType = dnsp.DNS_ZONE_TYPE_PRIMARY @@ -1089,6 +1089,10 @@ class TestZones(DNSTest): zone_create.fDsIntegrated = 1 zone_create.fLoadExisting = 1 zone_create.fAllowUpdate = dnsp.DNS_ZONE_UPDATE_UNSECURE + return zone_create + + def create_zone(self, zone, aging_enabled=False): + zone_create = self.make_zone_obj(zone, aging_enabled) try: client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN self.rpc_conn.DnssrvOperation2(client_version, @@ -1100,7 +1104,7 @@ class TestZones(DNSTest): dnsserver.DNSSRV_TYPEID_ZONE_CREATE, zone_create) except WERRORError as e: - self.fail(str(e)) + self.fail(e) def set_params(self, **kwargs): zone = kwargs.pop('zone', None) @@ -1546,6 +1550,59 @@ class TestZones(DNSTest): else: self.assertEqual(len(recs), 1) + def test_fully_qualified_zone(self): + + def create_zone_expect_exists(zone): + try: + zone_create = self.make_zone_obj(zone) + client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN + zc_type = dnsserver.DNSSRV_TYPEID_ZONE_CREATE + self.rpc_conn.DnssrvOperation2(client_version, + 0, + self.server_ip, + None, + 0, + 'ZoneCreate', + zc_type, + zone_create) + except WERRORError as e: + enum, _ = e.args + if enum != werror.WERR_DNS_ERROR_ZONE_ALREADY_EXISTS: + self.fail(e) + return + self.fail("Zone {} should already exist".format(zone)) + + # Create unqualified, then check creating qualified fails. + self.create_zone(self.zone) + create_zone_expect_exists(self.zone + '.') + + # Same again, but the other way around. + self.create_zone(self.zone + '2.') + create_zone_expect_exists(self.zone + '2') + + client_version = dnsserver.DNS_CLIENT_VERSION_LONGHORN + request_filter = dnsserver.DNS_ZONE_REQUEST_PRIMARY + tid = dnsserver.DNSSRV_TYPEID_DWORD + typeid, res = self.rpc_conn.DnssrvComplexOperation2(client_version, + 0, + self.server_ip, + None, + 'EnumZones', + tid, + request_filter) + + self.delete_zone(self.zone) + self.delete_zone(self.zone + '2') + + # Two zones should've been created, neither of them fully qualified. + zones_we_just_made = [] + zones = [str(z.pszZoneName) for z in res.ZoneArray] + for zone in zones: + if zone.startswith(self.zone): + zones_we_just_made.append(zone) + self.assertEqual(len(zones_we_just_made), 2) + self.assertEqual(set(zones_we_just_made), {self.zone + '2', self.zone}) + def delete_zone(self, zone): self.rpc_conn.DnssrvOperation2(dnsserver.DNS_CLIENT_VERSION_LONGHORN, 0, diff --git a/selftest/knownfail.d/dns b/selftest/knownfail.d/dns index ec345372046..10a6c03e0e1 100644 --- a/selftest/knownfail.d/dns +++ b/selftest/knownfail.d/dns @@ -50,6 +50,7 @@ samba.tests.dns.__main__.TestZones.test_dns_tombstone_custom_match_rule_no_recor samba.tests.dns.__main__.TestZones.test_dns_tombstone_custom_match_rule_fail\(rodc:local\) samba.tests.dns.__main__.TestZones.test_dynamic_record_static_update\(rodc:local\) samba.tests.dns.__main__.TestZones.test_static_record_dynamic_update\(rodc:local\) +samba.tests.dns.__main__.TestZones.test_fully_qualified_zone samba.tests.dns.__main__.TestZones.test_set_aging\(vampire_dc:local\) samba.tests.dns.__main__.TestZones.test_aging_update\(vampire_dc:local\)