def test_dns_update_all_zones_writes_trusted_networks_parameter(self): self.patch(settings, 'DNS_CONNECT', True) trusted_network = factory.make_ipv4_address() get_trusted_networks_patch = self.patch(dns_config_module, 'get_trusted_networks') get_trusted_networks_patch.return_value = [trusted_network] dns_update_all_zones() self.assertThat(compose_config_path(DNSConfig.target_file_name), FileContains(matcher=Contains(trusted_network)))
def test_dns_update_all_zones_writes_trusted_networks_params_extra(self): self.patch(settings, 'DNS_CONNECT', True) extra_trusted_network = factory.make_ipv6_network() get_trusted_acls_patch = self.patch( dns_config_module, 'get_trusted_acls') get_trusted_acls_patch.return_value = [extra_trusted_network.cidr] dns_update_all_zones() self.assertThat( compose_config_path(DNSConfig.target_file_name), FileContains(matcher=Contains(str(extra_trusted_network))))
def __init__(self, subnetwork, zone_name, target_path=None): """ :param subnetwork: IPNetwork that this zone (chunk) is for. None for forward zones. :param zone_name: Fully-qualified zone name :param target_path: Optional, can be used to override the target path. """ self.subnetwork = subnetwork self.zone_name = zone_name if target_path is None: self.target_path = compose_config_path("zone.%s" % zone_name) else: self.target_path = target_path
def __init__(self, domain, zone_info, serial=None, **kwargs): """ :param domain: An iterable list of domain names for the forward zone. :param ns_host_name: The name of the primary nameserver. :param zone_info: list of DomainInfo entries. :param serial: The serial to use in the zone file. This must increment on each change. :param ns_ttl: The TTL for the NS RRset. :param default_ttl: The default TTL for the zone. """ self.domain = domain self.ns_host_name = kwargs.pop("ns_host_name", None) self.serial = serial self.zone_info = zone_info self.target_base = compose_config_path("zone") self.default_ttl = kwargs.pop("default_ttl", 30) self.ns_ttl = kwargs.pop("ns_ttl", self.default_ttl)
def test_returns_filename_in_dns_config_dir(self): dns_dir = patch_dns_config_path(self) filename = factory.make_name("config") self.assertEqual(os.path.join(dns_dir, filename), compose_config_path(filename))