Ejemplo n.º 1
0
    def do_generic_add(self, ip_str, fqdn, ip_type, domain=None):
        ret = PTR(name=fqdn, ip_str=ip_str, ip_type=ip_type)
        ret.full_clean()
        ret.save()

        self.assertTrue(ret.details())
        self.assertTrue(ret.get_detail_url())
        self.assertTrue(ret.get_update_url())
        self.assertTrue(ret.get_delete_url())

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn,
                                 ip_upper=ip.ip_upper,
                                 ip_lower=ip.ip_lower)
        ptr.__repr__()
        self.assertTrue(ptr)
        ip_str = ip_str.lower()
        self.assertEqual(ptr[0].ip_str, ip_str)
        if domain:
            if ptr[0].name == "":
                self.assertEqual(fqdn, domain.name)
            else:
                self.assertEqual(fqdn, ptr[0].name + "." + domain.name)
        else:
            self.assertEqual(fqdn, ptr[0].name)
        return ret
Ejemplo n.º 2
0
    def do_generic_add(self, ip_str, fqdn, ip_type, domain=None):
        ret = PTR(name=fqdn, ip_str=ip_str, ip_type=ip_type)
        ret.full_clean()
        ret.save()

        self.assertTrue(ret.details())
        self.assertTrue(ret.get_detail_url())
        self.assertTrue(ret.get_update_url())
        self.assertTrue(ret.get_delete_url())

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn, ip_upper=ip.ip_upper, ip_lower=ip.ip_lower)
        ptr.__repr__()
        self.assertTrue(ptr)
        ip_str = ip_str.lower()
        self.assertEqual(ptr[0].ip_str, ip_str)
        if domain:
            if ptr[0].name == "":
                self.assertEqual(fqdn, domain.name)
            else:
                self.assertEqual(fqdn, ptr[0].name + "." + domain.name)
        else:
            self.assertEqual(fqdn, ptr[0].name)
        return ret
Ejemplo n.º 3
0
    def test_creation(self):
        rd = create_reverse_domain('130', ip_type='4')

        ip = Ip(ip_str="111:22:3::", ip_type='6')
        ip.clean_ip()

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
Ejemplo n.º 4
0
    def test_creation(self):
        rd = create_reverse_domain('130', ip_type='4')

        ip = Ip(ip_str="111:22:3::", ip_type='6')
        ip.clean_ip()

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
Ejemplo n.º 5
0
    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
Ejemplo n.º 6
0
    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
Ejemplo n.º 7
0
    def test_creation(self):
        rd = ReverseDomain(name="130", ip_type="4")
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
Ejemplo n.º 8
0
    def do_generic_remove(self, ip_str, fqdn, ip_type):
        ptr = PTR.objects.create(
            ip_str=ip_str, fqdn=fqdn, ip_type=ip_type, ctnr=self.c1)

        ptr.delete()

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        self.assertFalse(PTR.objects.filter(
            fqdn=fqdn, ip_upper=ip.ip_upper, ip_lower=ip.ip_lower).exists())
Ejemplo n.º 9
0
    def do_generic_remove(self, ip, fqdn, ip_type):
        ptr = PTR(ip_str=ip, name=fqdn, ip_type=ip_type)
        ptr.full_clean()
        ptr.save()

        ptr.delete()

        ip = Ip(ip_str=ip, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn, ip_upper=ip.ip_upper, ip_lower=ip.ip_lower)
        self.assertFalse(ptr)
Ejemplo n.º 10
0
 def test_large_ipv6(self):
     rd = create_reverse_domain('f', ip_type='6')
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2 ** 64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str, ip_upper=ip_upper,
                 ip_lower=ip_lower, ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
Ejemplo n.º 11
0
 def test_int_ip(self):
     rd = create_reverse_domain('129', ip_type='4')
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = create_reverse_domain('e', ip_type='6')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
Ejemplo n.º 12
0
 def test_int_ip(self):
     rd = create_reverse_domain('129', ip_type='4')
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = create_reverse_domain('e', ip_type='6')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
Ejemplo n.º 13
0
 def test_int_ip(self):
     rd = self.create_domain(name='129', ip_type='4')
     rd.save()
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = boot_strap_ipv6_reverse_domain('e')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
Ejemplo n.º 14
0
    def do_generic_remove(self, ip, fqdn, ip_type):
        ptr = PTR(ip_str=ip, name=fqdn, ip_type=ip_type)
        ptr.full_clean()
        ptr.save()

        ptr.delete()

        ip = Ip(ip_str=ip, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn,
                                 ip_upper=ip.ip_upper,
                                 ip_lower=ip.ip_lower)
        self.assertFalse(ptr)
Ejemplo n.º 15
0
 def test_int_ip(self):
     rd = self.create_domain(name='129', ip_type='4')
     rd.save()
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = boot_strap_ipv6_reverse_domain('e')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
Ejemplo n.º 16
0
 def test_int_ip(self):
     rd = ReverseDomain(name="129", ip_type="4")
     rd.save()
     ip = Ip(ip_str="129.193.1.1", ip_type="4")
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = boot_strap_ipv6_reverse_domain("e")
     ip_str = "efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
     ip = Ip(ip_str=ip_str, ip_type="6")
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
Ejemplo n.º 17
0
 def test_large_ipv6(self):
     rd = create_reverse_domain('f', ip_type='6')
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2**64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str,
                 ip_upper=ip_upper,
                 ip_lower=ip_lower,
                 ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
Ejemplo n.º 18
0
    def do_generic_remove(self, ip_str, fqdn, ip_type):
        ptr = PTR.objects.create(ip_str=ip_str,
                                 fqdn=fqdn,
                                 ip_type=ip_type,
                                 ctnr=self.c1)

        ptr.delete()

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        self.assertFalse(
            PTR.objects.filter(fqdn=fqdn,
                               ip_upper=ip.ip_upper,
                               ip_lower=ip.ip_lower).exists())
Ejemplo n.º 19
0
    def test_update_ipv4_str(self):
        ip_str = '66.168.1.1'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip = Ip(ip_str=ip_str, ip_type='4')
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))

        # Make sure ip_lower is update.
        ip_str = '66.213.1.9'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip.ip_str = ip_str
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))
Ejemplo n.º 20
0
    def test_update_ipv4_str(self):
        ip_str = '66.168.1.1'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip = Ip(ip_str=ip_str, ip_type='4')
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))

        # Make sure ip_lower is update.
        ip_str = '66.213.1.9'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip.ip_str = ip_str
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))
Ejemplo n.º 21
0
 def test_large_ipv6(self):
     try:
         rd = boot_strap_ipv6_reverse_domain('f')
         rd.save()
     except ValidationError:
         pass
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2 ** 64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str, ip_upper=ip_upper,
                 ip_lower=ip_lower, ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
Ejemplo n.º 22
0
 def test_large_ipv6(self):
     try:
         rd = boot_strap_ipv6_reverse_domain('f')
         rd.save()
     except ValidationError:
         pass
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2**64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str,
                 ip_upper=ip_upper,
                 ip_lower=ip_lower,
                 ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
Ejemplo n.º 23
0
    def test_ipv6_str(self):
        boot_strap_ipv6_reverse_domain('1.2.3.4')

        ip_str = '1234:1234:1243:1243:1243::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)

        ip_str = '1234:432:3:0:3414:22::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)
Ejemplo n.º 24
0
    def test_ipv6_str(self):
        rd = boot_strap_ipv6_reverse_domain('1.2.3.4')

        ip_str = '1234:1234:1243:1243:1243::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)

        ip_str = '1234:432:3:0:3414:22::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)
Ejemplo n.º 25
0
        ip.__repr__()

    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
        self.assertEqual(ValidationError, type(e))

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
        ip.clean_ip()
        self.assertTrue(ip.ip_upper == 0 and ip.ip_lower and ip.reverse_domain)

    def test_bad_create(self):
        ip = Ip(ip_str="66.193.1.2", ip_type='x')
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=None)
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=99)
        self.assertRaises(ValidationError, ip.clean_ip)

    def test_ipv6_to_longs(self):
        addr = "herp derp, not an ip"
        self.assertRaises(ValidationError, ipv6_to_longs, addr)

    def test1_ipv6_to_longs(self):
Ejemplo n.º 26
0
        ip.__repr__()

    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
        self.assertEqual(ValidationError, type(e))

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
        ip.clean_ip()
        self.assertTrue(
            ip.ip_upper == 0 and ip.ip_lower and ip.reverse_domain)

    def test_bad_create(self):
        ip = Ip(ip_str="66.193.1.2", ip_type='x')
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=None)
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=99)
        self.assertRaises(ValidationError, ip.clean_ip)

    def test_ipv6_to_longs(self):
        addr = "herp derp, not an ip"
        self.assertRaises(ValidationError, ipv6_to_longs, addr)