pvl/hosts/tests.py
changeset 473 68fd85d850ab
parent 472 814cc88c531b
child 474 51983fcda6b1
equal deleted inserted replaced
472:814cc88c531b 473:68fd85d850ab
   132 
   132 
   133         self.assertZoneEquals(zone.host_forward(h, 'domain'), {
   133         self.assertZoneEquals(zone.host_forward(h, 'domain'), {
   134             ('host', 'A'): ['192.0.2.1'],
   134             ('host', 'A'): ['192.0.2.1'],
   135             ('host', 'AAAA'): ['2001:db8::c000:201'],
   135             ('host', 'AAAA'): ['2001:db8::c000:201'],
   136         })
   136         })
   137 
       
   138         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.2.1/24'))), {
       
   139             ('1', 'PTR'): ['host.domain.'],
       
   140         })
       
   141 
       
   142         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('2001:db8::/64'))), {
       
   143             ('1.0.2.0.0.0.0.c.0.0.0.0.0.0.0.0', 'PTR'): ['host.domain.'],
       
   144         })
       
   145     
   137     
   146     def testHostAlias(self):
   138     def testHostAlias(self):
   147         h = host.Host.build('host', 'domain',
   139         h = host.Host.build('host', 'domain',
   148                 ip      = '192.0.2.1',
   140                 ip      = '192.0.2.1',
   149                 alias   = 'test *.test',
   141                 alias   = 'test *.test',
   325 class TestReverseZone(TestZoneMixin, unittest.TestCase):
   317 class TestReverseZone(TestZoneMixin, unittest.TestCase):
   326     def setUp(self):
   318     def setUp(self):
   327         self.options = Options()
   319         self.options = Options()
   328         self.options.unknown_host = False
   320         self.options.unknown_host = False
   329 
   321 
       
   322     def testHostIP(self):
       
   323         h = host.Host.build('host', 'domain',
       
   324                 ip  = '192.0.2.1',
       
   325                 ip6 = '2001:db8::192.0.2.1',
       
   326         )
       
   327 
       
   328         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.2.1/24'))), {
       
   329             ('1', 'PTR'): ['host.domain.'],
       
   330         })
       
   331 
       
   332         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('2001:db8::/64'))), {
       
   333             ('1.0.2.0.0.0.0.c.0.0.0.0.0.0.0.0', 'PTR'): ['host.domain.'],
       
   334         })
       
   335 
       
   336     def testHostIP4(self):
       
   337         h = host.Host.build('host', 'domain',
       
   338                 ip  = '192.0.2.1',
       
   339         )
       
   340 
       
   341         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.2.1/24'))), {
       
   342             ('1', 'PTR'): ['host.domain.'],
       
   343         })
       
   344 
       
   345         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('2001:db8::/64'))), {
       
   346 
       
   347         })
       
   348 
       
   349     def testHostIP6(self):
       
   350         h = host.Host.build('host', 'domain',
       
   351                 ip6 = '2001:db8::192.0.2.1',
       
   352         )
       
   353 
       
   354         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.2.1/24'))), {
       
   355         })
       
   356 
       
   357         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('2001:db8::/64'))), {
       
   358             ('1.0.2.0.0.0.0.c.0.0.0.0.0.0.0.0', 'PTR'): ['host.domain.'],
       
   359         })
       
   360 
       
   361     def testHostIPOutOfPrefix(self):
       
   362         h = host.Host.build('host', 'domain',
       
   363                 ip  = '192.0.2.1',
       
   364                 ip6 = '2001:db8::192.0.2.1',
       
   365         )
       
   366 
       
   367         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('192.0.1.0/24'))), {
       
   368 
       
   369         })
       
   370 
       
   371         self.assertZoneEquals((rr for ip, rr in zone.host_reverse(h, ipaddr.IPNetwork('2001:db8:1::/64'))), {
       
   372 
       
   373         })
       
   374 
   330     def testHostDelegate(self):
   375     def testHostDelegate(self):
   331         h = host.Host.build('host', 'example.com',
   376         h = host.Host.build('host', 'example.com',
   332                 ip      = '192.0.2.1',
   377                 ip      = '192.0.2.1',
   333                 ip6     = '2001:db8::192.0.2.1',
   378                 ip6     = '2001:db8::192.0.2.1',
   334                 forward = '',
   379                 forward = '',