Example #1
0
 def test_remove_reverse_domain(self):
     ReverseDomain(name='127',ip_type='4').save()
     rd1 = ReverseDomain(name = '127.193', ip_type='4')
     rd1.save()
     rd1.__repr__()
     rd1.__str__()
     rd2 = ReverseDomain(name = '127.193.8', ip_type='4')
     rd2.save()
     rd2.__repr__()
     rd2.__str__()
     ip1 = self.add_ptr_ipv4('127.193.8.1')
     self.assertEqual(ip1.reverse_domain, rd2)
     ip2 = self.add_ptr_ipv4('127.193.8.2')
     self.assertEqual(ip2.reverse_domain, rd2)
     ip3 = self.add_ptr_ipv4('127.193.8.3')
     self.assertEqual(ip3.reverse_domain, rd2)
     ip4 = self.add_ptr_ipv4('127.193.8.4')
     self.assertEqual(ip4.reverse_domain, rd2)
     rd2.delete()
     ptr1 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('127.193.8.1').__int__(), ip_type = '4')[0]
     self.assertEqual(ptr1.reverse_domain, rd1)
     ptr2 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('127.193.8.2').__int__(), ip_type = '4')[0]
     self.assertEqual(ptr2.reverse_domain, rd1)
     ptr3 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('127.193.8.2').__int__(), ip_type = '4')[0]
     self.assertEqual(ptr3.reverse_domain, rd1)
     ptr4 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('127.193.8.3').__int__(), ip_type = '4')[0]
     self.assertEqual(ptr4.reverse_domain, rd1)
Example #2
0
 def test_remove_invalid_reverse_domain(self):
     rd1 = ReverseDomain(name = '130', ip_type='4')
     rd1.save()
     rd2 = ReverseDomain(name = '130.193', ip_type='4')
     rd2.save()
     rd3 = ReverseDomain(name = '130.193.8', ip_type='4')
     rd3.save()
     try:
         rd1.delete()
     except ValidationError, e:
         pass
Example #3
0
    def test_add_remove_reverse_ipv6_domains(self):
        osu_block = "2620:105:F000"
        rd0 = boot_strap_ipv6_reverse_domain("2.6.2.0.0.1.0.5.f.0.0.0")

        ip1 = self.add_ptr_ipv6(osu_block+":8000::1")
        self.assertEqual(ip1.reverse_domain, rd0)
        ip2 = self.add_ptr_ipv6(osu_block+":8000::2")
        self.assertEqual(ip2.reverse_domain, rd0)
        ip3 = self.add_ptr_ipv6(osu_block+":8000::3")
        self.assertEqual(ip3.reverse_domain, rd0)
        ip4 = self.add_ptr_ipv6(osu_block+":8000::4")

        rd1 = ReverseDomain(name="2.6.2.0.0.1.0.5.f.0.0.0.8", ip_type='6')
        rd1.save()
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::1")
        ptr1 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr1.reverse_domain, rd1)
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::2")
        ptr2 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr2.reverse_domain, rd1)
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::3")
        ptr3 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr3.reverse_domain, rd1)
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::4")
        ptr4 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr4.reverse_domain, rd1)

        rd1.delete()

        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::1")
        ptr1 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr1.reverse_domain, rd0)
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::2")
        ptr2 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr2.reverse_domain, rd0)
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::3")
        ptr3 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr3.reverse_domain, rd0)
        ip_upper, ip_lower = ipv6_to_longs(osu_block+":8000::4")
        ptr4 = PTR.objects.filter(ip_upper = ip_upper, ip_lower = ip_lower , ip_type = '6')[0]
        self.assertEqual(ptr4.reverse_domain, rd0)
Example #4
0
        self.assertEqual(ip2.reverse_domain, rd0)
        ip3 = self.add_ptr_ipv4('128.193.8.3')
        self.assertEqual(ip3.reverse_domain, rd0)
        ip4 = self.add_ptr_ipv4('128.193.8.4')
        self.assertEqual(ip4.reverse_domain, rd0)
        rd1 = ReverseDomain(name = '128.193.8', ip_type='4')
        rd1.save()
        ptr1 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.1').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr1.reverse_domain, rd1)
        ptr2 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.2').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr2.reverse_domain, rd1)
        ptr3 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.3').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr3.reverse_domain, rd1)
        ptr4 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.4').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr4.reverse_domain, rd1)
        rd1.delete()
        ptr1 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.1').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr1.reverse_domain, rd0)
        ptr2 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.2').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr2.reverse_domain, rd0)
        ptr3 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.2').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr3.reverse_domain, rd0)
        ptr4 = PTR.objects.filter(ip_lower = ipaddr.IPv4Address('128.193.8.3').__int__(), ip_type = '4')[0]
        self.assertEqual(ptr4.reverse_domain, rd0)

    def test_boot_strap_add_ipv6_domain(self):
        osu_block = "2.6.2.1.1.0.5.F.0.0.0"
        test_dname = osu_block+".d.e.a.d.b.e.e.f"
        boot_strap_ipv6_reverse_domain(test_dname)
        try:
            ReverseDomain(name='2.6.2.1.1.0.5.f.0.0.0', ip_type='6').save()