def test_reverse_config_file_is_world_readable(self): self.patch(DNSReverseZoneConfig, 'target_dir', self.make_dir()) dns_zone_config = DNSReverseZoneConfig( factory.getRandomString(), serial=random.randint(1, 100), dns_ip=factory.getRandomIPAddress(), network=factory.getRandomNetwork()) dns_zone_config.write_config() filepath = FilePath(dns_zone_config.target_path) self.assertTrue(filepath.getPermissions().other.read)
def test_writes_reverse_dns_zone_config(self): target_dir = self.make_dir() self.patch(DNSReverseZoneConfig, 'target_dir', target_dir) domain = factory.getRandomString() network = IPNetwork('192.168.0.1/22') dns_zone_config = DNSReverseZoneConfig( domain, serial=random.randint(1, 100), network=network) dns_zone_config.write_config() reverse_file_name = 'zone.168.192.in-addr.arpa' expected = Contains( '10.0 IN PTR %s' % generated_hostname('192.168.0.10')) self.assertThat( os.path.join(target_dir, reverse_file_name), FileContains(matcher=expected))
def test_writes_dns_zone_config_with_NS_record(self): target_dir = self.make_dir() self.patch(DNSReverseZoneConfig, 'target_dir', target_dir) network = factory.getRandomNetwork() dns_ip = factory.getRandomIPAddress() dns_zone_config = DNSReverseZoneConfig( factory.getRandomString(), serial=random.randint(1, 100), dns_ip=dns_ip, network=network) dns_zone_config.write_config() self.assertThat( os.path.join( target_dir, 'zone.%s' % dns_zone_config.zone_name), FileContains( matcher=Contains('IN NS %s.' % dns_zone_config.domain)))