Beispiel #1
0
 def test_add_addr_creates_public_records(self):
     self.z.add_addr('vm00', ip.IPAddress('195.62.125.33'), ['vm00.ipv4'])
     self.assertIn(RR.A('vm00', ip.IPAddress('195.62.125.33')),
                   self.z.external_forward.records)
     self.assertIn(RR.A('vm00', ip.IPAddress('195.62.125.33')),
                   self.z.internal_forward.records)
     self.assertIn(RR.CNAME('vm00.ipv4', 'vm00'),
                   self.z.external_forward.records)
     self.assertIn(RR.CNAME('vm00.ipv4', 'vm00'),
                   self.z.internal_forward.records)
Beispiel #2
0
 def test_add_ptr_strips_prefix(self):
     z = ReverseZone('1.0.1.0.8.4.2.0.2.0.a.2.ip6.arpa',
                     ip.IPNetwork('2a02:238:101::/48'))
     z.add_ptr(ip.IPAddress('2a02:248:101:63::5b'), 'vm00')
     self.assertEqual(
         RR.PTR('b.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.6.0.0', 'vm00'),
         z.records[0])
Beispiel #3
0
 def test_save_returns_true_if_changed(self, now):
     now.return_value = datetime.datetime(2014, 2, 17, tzinfo=pytz.utc)
     with open(self.filename, 'w') as f:
         f.write(self.z.render(2014021703))
     self.z.records.append(RR.A('vm01', ip.IPAddress('192.168.1.1')))
     self.assertTrue(self.z.save())
     with open(self.filename) as f:
         self.assertEqual(f.read(), self.z.render(2014021704))
Beispiel #4
0
 def test_first_cname_wins(self):
     z = ForwardZone('gocept.net')
     z.add_cname('vm00', 'first')
     z.add_cname('vm00', 'second')
     self.assertEqual([RR.CNAME('vm00', 'first')], z.records)
Beispiel #5
0
 def test_forward_ipv6(self):
     z = ForwardZone('gocept.net')
     z.add_a('vm00.srv.whq', ip.IPAddress('2a02:248:101:63::5b'))
     self.assertIn(
         RR.AAAA('vm00.srv.whq', ip.IPAddress('2a02:248:101:63::5b')),
         z.records)
Beispiel #6
0
 def test_forward_ipv4(self):
     z = ForwardZone('gocept.net')
     z.add_a('vm00.fe.whq', ip.IPAddress('195.62.125.10'))
     self.assertIn(RR.A('vm00.fe.whq', ip.IPAddress('195.62.125.10')),
                   z.records)
Beispiel #7
0
 def test_add_addr_creates_no_public_records(self):
     self.z.add_addr('vm00', ip.IPAddress('172.22.48.20'), ['vm00.ipv4'])
     self.assertNotIn(RR.A('vm00', ip.IPAddress('172.22.48.20')),
                      self.z.external_forward.records)
     self.assertNotIn(RR.CNAME('vm00.ipv4', 'vm00'),
                      self.z.external_forward.records)
Beispiel #8
0
 def test_add_pre_strips_correct_prefix_for_cidr_zones(self):
     z = ReverseZone('128-25.41.122.212.in-addr.arpa',
                     prefix=ip.IPNetwork('212.122.41.128/25'),
                     strip_suffix='41.122.212.in-addr.arpa')
     z.add_ptr(ip.IPAddress('212.122.41.152'), 'rt.gocept.com.')
     self.assertEqual(RR.PTR('152', 'rt.gocept.com.'), z.records[0])