Esempio n. 1
0
 def test_master_domain(self):
     rd1 = create_reverse_domain('128', ip_type='4')
     rd2 = create_reverse_domain('128.193', ip_type='4')
     rd3 = create_reverse_domain('128.193.8', ip_type='4')
     self.assertEqual(rd3.master_domain, rd2)
     self.assertEqual(rd2.master_domain, rd1)
     self.assertEqual(rd1.master_domain.name, 'in-addr.arpa')
Esempio n. 2
0
    def setUp(self):
        super(PTRTests, self).setUp()

        Vrf.objects.create(name='test_vrf')

        self._128 = create_zone('128.in-addr.arpa')
        create_zone('8.ip6.arpa')

        self.c1 = Ctnr.objects.create(name='test_ctnr1')

        self.n = Network.objects.create(
            vrf=Vrf.objects.get(name='test_vrf'), ip_type='4',
            network_str='128.193.0.0/24')

        self.r = Range.objects.create(
            network=self.n, range_type='st', start_str='128.193.0.2',
            end_str='128.193.0.100')
        self.c1.ranges.add(self.r)

        for name in ('edu', 'oregonstate.edu', 'bar.oregonstate.edu',
                     'nothing', 'nothing.nothing', 'nothing.nothing.nothing'):
            d = Domain.objects.create(name=name)
            self.c1.domains.add(d)

        create_reverse_domain('8.6.2.0', ip_type='6')

        self.osu_block = "8620:105:F000:"
        self.create_network_range(
            network_str="8620:105::/32", start_str='8620:105:F000::1',
            end_str='8620:105:F000::1000', ip_type='6')
Esempio n. 3
0
 def test_master_domain(self):
     rd1 = create_reverse_domain('128', ip_type='4')
     rd2 = create_reverse_domain('128.193', ip_type='4')
     rd3 = create_reverse_domain('128.193.8', ip_type='4')
     self.assertEqual(rd3.master_domain, rd2)
     self.assertEqual(rd2.master_domain, rd1)
     self.assertEqual(rd1.master_domain.name, 'in-addr.arpa')
Esempio n. 4
0
    def setUp(self):
        super(PTRTests, self).setUp()

        Vrf.objects.create(name='test_vrf')

        self._128 = create_zone('128.in-addr.arpa')
        create_zone('8.ip6.arpa')

        self.c1 = Ctnr.objects.create(name='test_ctnr1')

        self.n = Network.objects.create(vrf=Vrf.objects.get(name='test_vrf'),
                                        ip_type='4',
                                        network_str='128.193.0.0/24')

        self.r = Range.objects.create(network=self.n,
                                      range_type='st',
                                      start_str='128.193.0.2',
                                      end_str='128.193.0.100')
        self.c1.ranges.add(self.r)

        for name in ('edu', 'oregonstate.edu', 'bar.oregonstate.edu',
                     'nothing', 'nothing.nothing', 'nothing.nothing.nothing'):
            d = Domain.objects.create(name=name)
            self.c1.domains.add(d)

        create_reverse_domain('8.6.2.0', ip_type='6')

        self.osu_block = "8620:105:F000:"
        self.create_network_range(network_str="8620:105::/32",
                                  start_str='8620:105:F000::1',
                                  end_str='8620:105:F000::1000',
                                  ip_type='6')
Esempio n. 5
0
    def test_add_remove_reverse_ipv6_zones(self):
        osu_block = "2620:105:F000"
        rd0 = create_reverse_domain('2.6.2.0.0.1.0.5.f.0.0.0', ip_type='6')
        rd0 = make_root(rd0)

        p1 = self.add_ptr_ipv6(osu_block + ":8000::1")
        self.assertEqual(p1.reverse_domain, rd0)
        p2 = self.add_ptr_ipv6(osu_block + ":8000::2")
        self.assertEqual(p2.reverse_domain, rd0)
        p3 = self.add_ptr_ipv6(osu_block + ":8000::3")
        self.assertEqual(p3.reverse_domain, rd0)
        p4 = self.add_ptr_ipv6(osu_block + ":8000::4")
        self.assertEqual(p4.reverse_domain, rd0)

        rd1 = create_reverse_domain('2.6.2.0.0.1.0.5.f.0.0.0.8', ip_type='6')
        rd1 = make_root(rd1)

        for ptr in (p1, p2, p3, p4):
            self.assertEqual(ptr.reload().reverse_domain, rd1)

        rd1.soa.delete()
        rd1.nameserver_set.get().delete()
        rd1.delete()

        for ptr in (p1, p2, p3, p4):
            self.assertEqual(ptr.reload().reverse_domain, rd0)
Esempio n. 6
0
    def test_invalid_name(self):
        osu_block = "7620:105:F000:"
        create_reverse_domain('7.6.2.0', ip_type='6')
        a_v4 = self.create_ar(label='bar',
                              domain=self.m_o_e,
                              ip_str="128.193.23.1",
                              ip_type='4')
        a_v6 = self.create_ar(label='baz',
                              domain=self.m_o_e,
                              ip_str=(osu_block + ':1'),
                              ip_type='6')

        for label in ('.', ' sdfsa ', 'asdf.', '%asdfsaf'):
            self.assertRaises(ValidationError,
                              self.create_ar,
                              label=label,
                              domain=self.f_o_e,
                              ip_str='128.193.23.2',
                              ip_type='4')

            self.assertRaises(ValidationError,
                              self.create_ar,
                              label=label,
                              domain=self.f_o_e,
                              ip_str=(osu_block + ':2'),
                              ip_type='6')

            a_v4.label = label
            self.assertRaises(ValidationError, a_v4.save)

            a_v6.label = label
            self.assertRaises(ValidationError, a_v6.save)
Esempio n. 7
0
    def test_add_remove_reverse_ipv6_zones(self):
        osu_block = "2620:105:F000"
        rd0 = create_reverse_domain('2.6.2.0.0.1.0.5.f.0.0.0', ip_type='6')
        rd0 = make_root(rd0)

        p1 = self.add_ptr_ipv6(osu_block + ":8000::1")
        self.assertEqual(p1.reverse_domain, rd0)
        p2 = self.add_ptr_ipv6(osu_block + ":8000::2")
        self.assertEqual(p2.reverse_domain, rd0)
        p3 = self.add_ptr_ipv6(osu_block + ":8000::3")
        self.assertEqual(p3.reverse_domain, rd0)
        p4 = self.add_ptr_ipv6(osu_block + ":8000::4")
        self.assertEqual(p4.reverse_domain, rd0)

        rd1 = create_reverse_domain('2.6.2.0.0.1.0.5.f.0.0.0.8', ip_type='6')
        rd1 = make_root(rd1)

        for ptr in (p1, p2, p3, p4):
            self.assertEqual(ptr.reload().reverse_domain, rd1)

        rd1.soa.delete()
        rd1.nameserver_set.get().delete()
        rd1.delete()

        for ptr in (p1, p2, p3, p4):
            self.assertEqual(ptr.reload().reverse_domain, rd0)
Esempio n. 8
0
 def test_remove_AAAA_address_records(self):
     osu_block = "4620:105:F000:"
     create_reverse_domain('4.6.2.0', ip_type='6')
     self.create_delete_A(label="",
                          domain=self.o_e,
                          ip_str=(osu_block + ":1"),
                          ip_type='6')
     self.create_delete_A(label="please",
                          domain=self.o_e,
                          ip_str=(osu_block + ":2"),
                          ip_type='6')
     self.create_delete_A(label="visit",
                          domain=self.o_e,
                          ip_str=(osu_block + ":4"),
                          ip_type='6')
     self.create_delete_A(label="from",
                          domain=self.o_e,
                          ip_str=(osu_block + ":2"),
                          ip_type='6')
     self.create_delete_A(label="either",
                          domain=self.o_e,
                          ip_str=(osu_block + ":1"),
                          ip_type='6')
     self.create_delete_A(label="webpages",
                          domain=self.o_e,
                          ip_str=(osu_block + ":1"),
                          ip_type='6')
     self.create_delete_A(label="read",
                          domain=self.o_e,
                          ip_str=(osu_block + ":1"),
                          ip_type='6')
Esempio n. 9
0
    def test_invalid_name(self):
        osu_block = "7620:105:F000:"
        create_reverse_domain('7.6.2.0', ip_type='6')
        a_v4 = self.create_ar(
            label='bar', domain=self.m_o_e, ip_str="128.193.23.1", ip_type='4')
        a_v6 = self.create_ar(
            label='baz', domain=self.m_o_e, ip_str=(osu_block + ':1'),
            ip_type='6')

        for label in ('.', ' sdfsa ', 'asdf.', '%asdfsaf'):
            self.assertRaises(
                ValidationError, self.create_ar,
                label=label, domain=self.f_o_e, ip_str='128.193.23.2',
                ip_type='4')

            self.assertRaises(
                ValidationError, self.create_ar,
                label=label, domain=self.f_o_e, ip_str=(osu_block + ':2'),
                ip_type='6')

            a_v4.label = label
            self.assertRaises(ValidationError, a_v4.save)

            a_v6.label = label
            self.assertRaises(ValidationError, a_v6.save)
Esempio n. 10
0
    def test_add_reverse_domainless_ips(self):
        self.assertRaises(ValidationError, self.add_ptr_ipv4, ip='8.8.8.8')
        self.assertRaises(ValidationError, self.add_ptr_ipv6,
                          ip='2001:0db8:85a3:0000:0000:8a2e:0370:733')

        create_zone('2.ip6.arpa')
        create_reverse_domain('2.0.0.1', ip_type='6')
        self.add_ptr_ipv6('2001:0db8:85a3:0000:0000:8a2e:0370:733')
Esempio n. 11
0
    def test_add_reverse_domainless_ips(self):
        self.assertRaises(ValidationError, self.add_ptr_ipv4, ip='8.8.8.8')
        self.assertRaises(ValidationError, self.add_ptr_ipv6,
                          ip='2001:0db8:85a3:0000:0000:8a2e:0370:733')

        create_zone('2.ip6.arpa')
        create_reverse_domain('2.0.0.1', ip_type='6')
        self.add_ptr_ipv6('2001:0db8:85a3:0000:0000:8a2e:0370:733')
Esempio n. 12
0
    def test_ipv4_str(self):
        rd = create_reverse_domain('192', ip_type='4')
        ip_str = '192.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()

        rd = create_reverse_domain('128', ip_type='4')
        ip_str = '128.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()
Esempio n. 13
0
    def test_ipv4_str(self):
        rd = create_reverse_domain('192', ip_type='4')
        ip_str = '192.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()

        rd = create_reverse_domain('128', ip_type='4')
        ip_str = '128.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()
Esempio n. 14
0
    def test_update_v6(self):
        create_reverse_domain('8.6.2.0', ip_type='6')
        osu_block = "8620:105:F000:"
        rec0 = self.create_ar(label='',
                              domain=self.z_o_e,
                              ip_str=(osu_block + ":1"),
                              ip_type='6')
        rec1 = self.create_ar(label='foo',
                              domain=self.z_o_e,
                              ip_str=(osu_block + ":1"),
                              ip_type='6')
        rec2 = self.create_ar(label='bar',
                              domain=self.z_o_e,
                              ip_str=(osu_block + ":1"),
                              ip_type='6')

        rec0.label = 'whoooooasfjsp1'
        rec0.ip_str = osu_block + '0:0:123:321::'
        rec0.save()

        rec1.label = "wasfasfsafdhooooop1"
        rec1.ip_str = osu_block + "0:0:123:321::"
        rec1.save()

        rec2.label = "whoooooasfdisafsap1"
        rec2.ip_str = osu_block + "0:24:123:322:1"
        rec2.save()

        rec0.label = "whooooop1"
        rec0.ip_str = osu_block + "0:aaa::1"
        rec0.save()

        rec0.label = "wasflasksdfhooooop1"
        rec0.ip_str = osu_block + "0:dead::"
        rec0.save()

        rec1.label = "whooooosf13fp1"
        rec1.ip_str = osu_block + "0:0::"
        rec1.save()

        rec1.label = "whooooodfijasf1"
        rec1.ip_str = osu_block + "0:1:23::"
        rec1.save()

        rec2.label = "lliasdflsafwhooooop1"
        rec2.ip_str = osu_block + ":"
        rec2.save()

        rec1.label = "whooooopsjafasf1"
        rec1.ip_str = osu_block + "0::"
        rec1.save()

        rec1.label = ""
        rec1.ip_str = osu_block + "0:0:123:321::"
        rec1.save()
Esempio n. 15
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__()
Esempio n. 16
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__()
Esempio n. 17
0
    def test_add_AAAA_invalid_address_records(self):
        osu_block = "3620:105:F000:"
        create_reverse_domain('3.6.2.0', ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='foo.nas',
                          domain=self.o_e,
                          ip_str=(osu_block + ':1'),
                          ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='foo.bar.nas',
                          domain=self.o_e,
                          ip_str=(osu_block + ':2'),
                          ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='foo.baz.bar.nas',
                          domain=self.o_e,
                          ip_str=(osu_block + ':3'),
                          ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='n as',
                          domain=self.o_e,
                          ip_str=(osu_block + ':4'),
                          ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='n!+/*&#@as',
                          domain=self.o_e,
                          ip_str=(osu_block + ':5'),
                          ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='n%as',
                          domain=self.o_e,
                          ip_str=(osu_block + ':6'),
                          ip_type='6')

        self.assertRaises(ValidationError,
                          self.create_ar,
                          label='n+as',
                          domain=self.o_e,
                          ip_str=(osu_block + ':7'),
                          ip_type='6')
Esempio n. 18
0
    def test_update_v6(self):
        create_reverse_domain('8.6.2.0', ip_type='6')
        osu_block = "8620:105:F000:"
        rec0 = self.create_ar(
            label='', domain=self.z_o_e, ip_str=(osu_block + ":1"),
            ip_type='6')
        rec1 = self.create_ar(
            label='foo', domain=self.z_o_e, ip_str=(osu_block + ":1"),
            ip_type='6')
        rec2 = self.create_ar(
            label='bar', domain=self.z_o_e, ip_str=(osu_block + ":1"),
            ip_type='6')

        rec0.label = 'whoooooasfjsp1'
        rec0.ip_str = osu_block + '0:0:123:321::'
        rec0.save()

        rec1.label = "wasfasfsafdhooooop1"
        rec1.ip_str = osu_block + "0:0:123:321::"
        rec1.save()

        rec2.label = "whoooooasfdisafsap1"
        rec2.ip_str = osu_block + "0:24:123:322:1"
        rec2.save()

        rec0.label = "whooooop1"
        rec0.ip_str = osu_block + "0:aaa::1"
        rec0.save()

        rec0.label = "wasflasksdfhooooop1"
        rec0.ip_str = osu_block + "0:dead::"
        rec0.save()

        rec1.label = "whooooosf13fp1"
        rec1.ip_str = osu_block + "0:0::"
        rec1.save()

        rec1.label = "whooooodfijasf1"
        rec1.ip_str = osu_block + "0:1:23::"
        rec1.save()

        rec2.label = "lliasdflsafwhooooop1"
        rec2.ip_str = osu_block + ":"
        rec2.save()

        rec1.label = "whooooopsjafasf1"
        rec1.ip_str = osu_block + "0::"
        rec1.save()

        rec1.label = ""
        rec1.ip_str = osu_block + "0:0:123:321::"
        rec1.save()
Esempio n. 19
0
    def test_add_AAAA_address_records(self):
        osu_block = "2620:105:F000:"
        create_reverse_domain('2.6.2.0', ip_type='6')

        self.create_ar(label='',
                       domain=self.f_o_e,
                       ip_str=(osu_block + ':4'),
                       ip_type='6')
        self.create_ar(label='',
                       domain=self.o_e,
                       ip_str=(osu_block + ':1'),
                       ip_type='6')
        self.create_ar(label='6ba-r',
                       domain=self.o_e,
                       ip_str=(osu_block + ':6'),
                       ip_type='6')
        self.create_ar(label='6ba-r',
                       domain=self.f_o_e,
                       ip_str=(osu_block + ':7'),
                       ip_type='6')
        self.create_ar(label='6foo',
                       domain=self.f_o_e,
                       ip_str=(osu_block + ':5'),
                       ip_type='6')
        self.create_ar(label='6foo',
                       domain=self.o_e,
                       ip_str=(osu_block + ':3'),
                       ip_type='6')
        self.create_ar(label='6ba3z',
                       domain=self.o_e,
                       ip_str=(osu_block + ':4'),
                       ip_type='6')
        self.create_ar(label='6ba3z',
                       domain=self.f_o_e,
                       ip_str=(osu_block + ':6'),
                       ip_type='6')
        self.create_ar(label='6foob1ar',
                       domain=self.o_e,
                       ip_str=(osu_block + ':5'),
                       ip_type='6')
        self.create_ar(label='6foob1ar',
                       domain=self.f_o_e,
                       ip_str=(osu_block + ':8'),
                       ip_type='6')
        self.create_ar(label='23412341253254243',
                       domain=self.f_o_e,
                       ip_str=(osu_block + ':8'),
                       ip_type='6')
Esempio n. 20
0
    def test_invalid_ip_v6(self):
        osu_block = "7620:105:F000:"
        create_reverse_domain('7.6.2.0', ip_type='6')
        a_v6 = self.create_ar(
            label='bar', domain=self.m_o_e, ip_str=(osu_block + ':1'),
            ip_type='6')

        bad_ips = (
            71134, osu_block + ':::', osu_block, 123981247293462847,
            '128.193.1.1')
        for ip_str in bad_ips:
            self.assertRaises(
                ValidationError, self.create_ar,
                label='baz', domain=self.m_o_e, ip_str=ip_str, ip_type='6')

            a_v6.ip_str = ip_str
            self.assertRaises(ValidationError, a_v6.save)
Esempio n. 21
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)
Esempio n. 22
0
    def test_duplicate(self):
        ### IPv4 ###

        def a1():
            self.create_ar(label='', domain=self.f_o_e, ip_str='128.193.0.2')

        a1()
        self.assertRaises(ValidationError, a1)

        def a2():
            self.create_ar(label='a2', domain=self.f_o_e, ip_str='128.193.0.2')

        a2()
        self.assertRaises(ValidationError, a2)

        ### IPv6 ###

        osu_block = "9620:105:F000:"
        create_reverse_domain('9.6.2.0', ip_type='6')

        def a3():
            self.create_ar(label='a3',
                           domain=self.f_o_e,
                           ip_str=(osu_block + ':2'),
                           ip_type='6')

        a3()
        self.assertRaises(ValidationError, a3)

        def a4():
            self.create_ar(label='a4',
                           domain=self.f_o_e,
                           ip_str=(osu_block + ':0:9'),
                           ip_type='6')

        a4()
        self.assertRaises(ValidationError, a4)

        def a5():
            self.create_ar(label='nope',
                           domain=self.o_e,
                           ip_str=(osu_block + ':4'),
                           ip_type='6')

        a5()
        self.assertRaises(ValidationError, a5)
Esempio n. 23
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)
Esempio n. 24
0
    def test_ipv6_str(self):
        create_reverse_domain('1.2.3.4', '6')

        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)
Esempio n. 25
0
    def test_ipv6_str(self):
        create_reverse_domain('1.2.3.4', '6')

        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)
Esempio n. 26
0
    def test_duplicate(self):
        ### IPv4 ###

        def a1():
            self.create_ar(label='', domain=self.f_o_e, ip_str='128.193.0.2')

        a1()
        self.assertRaises(ValidationError, a1)

        def a2():
            self.create_ar(label='a2', domain=self.f_o_e, ip_str='128.193.0.2')

        a2()
        self.assertRaises(ValidationError, a2)

        ### IPv6 ###

        osu_block = "9620:105:F000:"
        create_reverse_domain('9.6.2.0', ip_type='6')

        def a3():
            self.create_ar(
                label='a3', domain=self.f_o_e, ip_str=(osu_block + ':2'),
                ip_type='6')

        a3()
        self.assertRaises(ValidationError, a3)

        def a4():
            self.create_ar(
                label='a4', domain=self.f_o_e, ip_str=(osu_block + ':0:9'),
                ip_type='6')

        a4()
        self.assertRaises(ValidationError, a4)

        def a5():
            self.create_ar(
                label='nope', domain=self.o_e, ip_str=(osu_block + ':4'),
                ip_type='6')

        a5()
        self.assertRaises(ValidationError, a5)
Esempio n. 27
0
    def test_invalid_ip_v6(self):
        osu_block = "7620:105:F000:"
        create_reverse_domain('7.6.2.0', ip_type='6')
        a_v6 = self.create_ar(label='bar',
                              domain=self.m_o_e,
                              ip_str=(osu_block + ':1'),
                              ip_type='6')

        bad_ips = (71134, osu_block + ':::', osu_block, 123981247293462847,
                   '128.193.1.1')
        for ip_str in bad_ips:
            self.assertRaises(ValidationError,
                              self.create_ar,
                              label='baz',
                              domain=self.m_o_e,
                              ip_str=ip_str,
                              ip_type='6')

            a_v6.ip_str = ip_str
            self.assertRaises(ValidationError, a_v6.save)
Esempio n. 28
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__())
Esempio n. 29
0
    def setUp(self):
        super(AddressRecordTests, self).setUp()

        Vrf.objects.create(name='test_vrf')

        self.osu_block = "633:105:F000:"
        create_reverse_domain('0.6.3', ip_type='4')

        self.e = Domain.objects.create(name='edu')
        self.o_e = Domain.objects.create(name='oregonstate.edu')
        self.f_o_e = Domain.objects.create(name='fooz.oregonstate.edu')
        self.m_o_e = Domain.objects.create(name='max.oregonstate.edu')
        self.z_o_e = Domain.objects.create(name='zax.oregonstate.edu')
        self.g_o_e = Domain.objects.create(name='george.oregonstate.edu')

        self._128 = create_zone('128.in-addr.arpa')

        self._128_193 = create_reverse_domain('128.193', ip_type='4')

        for dom in (self.e, self.o_e, self.f_o_e, self.m_o_e, self.z_o_e,
                    self.g_o_e, self._128, self._128_193):
            self.ctnr.domains.add(dom)
Esempio n. 30
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__())
Esempio n. 31
0
    def setUp(self):
        super(AddressRecordTests, self).setUp()

        Vrf.objects.create(name='test_vrf')

        self.osu_block = "633:105:F000:"
        create_reverse_domain('0.6.3', ip_type='4')

        self.e = Domain.objects.create(name='edu')
        self.o_e = Domain.objects.create(name='oregonstate.edu')
        self.f_o_e = Domain.objects.create(name='fooz.oregonstate.edu')
        self.m_o_e = Domain.objects.create(name='max.oregonstate.edu')
        self.z_o_e = Domain.objects.create(name='zax.oregonstate.edu')
        self.g_o_e = Domain.objects.create(name='george.oregonstate.edu')

        self._128 = create_zone('128.in-addr.arpa')

        self._128_193 = create_reverse_domain('128.193', ip_type='4')

        for dom in (self.e, self.o_e, self.f_o_e, self.m_o_e, self.z_o_e,
                    self.g_o_e, self._128, self._128_193):
            self.ctnr.domains.add(dom)
Esempio n. 32
0
    def test_add_reverse_domains(self):
        create_reverse_domain('192.168', ip_type='4')

        create_zone('127.in-addr.arpa')
        rd0 = create_zone('193.127.in-addr.arpa')

        p1 = self.add_ptr_ipv4('127.193.8.1')
        self.assertEqual(p1.reverse_domain, rd0)
        p2 = self.add_ptr_ipv4('127.193.8.2')
        self.assertEqual(p2.reverse_domain, rd0)
        p3 = self.add_ptr_ipv4('127.193.8.3')
        self.assertEqual(p3.reverse_domain, rd0)
        p4 = self.add_ptr_ipv4('127.193.8.4')
        self.assertEqual(p4.reverse_domain, rd0)

        rd1 = create_zone('8.193.127.in-addr.arpa')

        p1 = p1.reload()
        self.assertEqual(p1.reverse_domain, rd1)
        p2 = p2.reload()
        self.assertEqual(p2.reverse_domain, rd1)
        p3 = p3.reload()
        self.assertEqual(p3.reverse_domain, rd1)
        p4 = p4.reload()
        self.assertEqual(p4.reverse_domain, rd1)

        rd1.soa.delete()
        rd1.nameserver_set.get().delete()
        rd1.delete()

        p1 = p1.reload()
        self.assertEqual(p1.reverse_domain, rd0)
        p2 = p2.reload()
        self.assertEqual(p2.reverse_domain, rd0)
        p3 = p3.reload()
        self.assertEqual(p3.reverse_domain, rd0)
        p4 = p4.reload()
        self.assertEqual(p4.reverse_domain, rd0)
Esempio n. 33
0
    def test_add_AAAA_invalid_address_records(self):
        osu_block = "3620:105:F000:"
        create_reverse_domain('3.6.2.0', ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='foo.nas', domain=self.o_e, ip_str=(osu_block + ':1'),
            ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='foo.bar.nas', domain=self.o_e, ip_str=(osu_block + ':2'),
            ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='foo.baz.bar.nas', domain=self.o_e,
            ip_str=(osu_block + ':3'), ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='n as', domain=self.o_e, ip_str=(osu_block + ':4'),
            ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='n!+/*&#@as', domain=self.o_e, ip_str=(osu_block + ':5'),
            ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='n%as', domain=self.o_e, ip_str=(osu_block + ':6'),
            ip_type='6')

        self.assertRaises(
            ValidationError, self.create_ar,
            label='n+as', domain=self.o_e, ip_str=(osu_block + ':7'),
            ip_type='6')
Esempio n. 34
0
    def test_add_reverse_domains(self):
        create_reverse_domain('192.168', ip_type='4')

        create_zone('127.in-addr.arpa')
        rd0 = create_zone('193.127.in-addr.arpa')

        p1 = self.add_ptr_ipv4('127.193.8.1')
        self.assertEqual(p1.reverse_domain, rd0)
        p2 = self.add_ptr_ipv4('127.193.8.2')
        self.assertEqual(p2.reverse_domain, rd0)
        p3 = self.add_ptr_ipv4('127.193.8.3')
        self.assertEqual(p3.reverse_domain, rd0)
        p4 = self.add_ptr_ipv4('127.193.8.4')
        self.assertEqual(p4.reverse_domain, rd0)

        rd1 = create_zone('8.193.127.in-addr.arpa')

        p1 = p1.reload()
        self.assertEqual(p1.reverse_domain, rd1)
        p2 = p2.reload()
        self.assertEqual(p2.reverse_domain, rd1)
        p3 = p3.reload()
        self.assertEqual(p3.reverse_domain, rd1)
        p4 = p4.reload()
        self.assertEqual(p4.reverse_domain, rd1)

        rd1.soa.delete()
        rd1.nameserver_set.get().delete()
        rd1.delete()

        p1 = p1.reload()
        self.assertEqual(p1.reverse_domain, rd0)
        p2 = p2.reload()
        self.assertEqual(p2.reverse_domain, rd0)
        p3 = p3.reload()
        self.assertEqual(p3.reverse_domain, rd0)
        p4 = p4.reload()
        self.assertEqual(p4.reverse_domain, rd0)
Esempio n. 35
0
 def test_remove_AAAA_address_records(self):
     osu_block = "4620:105:F000:"
     create_reverse_domain('4.6.2.0', ip_type='6')
     self.create_delete_A(
         label="", domain=self.o_e, ip_str=(osu_block + ":1"), ip_type='6')
     self.create_delete_A(
         label="please", domain=self.o_e, ip_str=(osu_block + ":2"),
         ip_type='6')
     self.create_delete_A(
         label="visit", domain=self.o_e, ip_str=(osu_block + ":4"),
         ip_type='6')
     self.create_delete_A(
         label="from", domain=self.o_e, ip_str=(osu_block + ":2"),
         ip_type='6')
     self.create_delete_A(
         label="either", domain=self.o_e, ip_str=(osu_block + ":1"),
         ip_type='6')
     self.create_delete_A(
         label="webpages", domain=self.o_e, ip_str=(osu_block + ":1"),
         ip_type='6')
     self.create_delete_A(
         label="read", domain=self.o_e, ip_str=(osu_block + ":1"),
         ip_type='6')
Esempio n. 36
0
    def test_soa_validators(self):
        m = create_reverse_domain('8', ip_type='4')
        f_m = create_reverse_domain('8.2', ip_type='4')
        n_f_m = create_reverse_domain('8.2.3', ip_type='4')
        b_m = create_reverse_domain('8.3', ip_type='4')

        s = SOA.objects.create(
            primary="ns1.foo.com", contact="asdf", description="test",
            root_domain=f_m)

        n_f_m = n_f_m.reload()
        self.assertEqual(n_f_m.soa, s)

        s.root_domain = m
        s.save()

        b_m = b_m.reload()
        self.assertEqual(b_m.soa, s)

        self.assertRaises(
            ValidationError, SOA.objects.create,
            primary="ns2.foo.com", contact="asdf", description="test2",
            root_domain=m)
Esempio n. 37
0
    def test_soa_validators(self):
        m = create_reverse_domain('8', ip_type='4')
        f_m = create_reverse_domain('8.2', ip_type='4')
        n_f_m = create_reverse_domain('8.2.3', ip_type='4')
        b_m = create_reverse_domain('8.3', ip_type='4')

        s = SOA.objects.create(
            primary="ns1.foo.com", contact="asdf", description="test",
            root_domain=f_m)

        n_f_m = n_f_m.reload()
        self.assertEqual(n_f_m.soa, s)

        s.root_domain = m
        s.save()

        b_m = b_m.reload()
        self.assertEqual(b_m.soa, s)

        self.assertRaises(
            ValidationError, SOA.objects.create,
            primary="ns2.foo.com", contact="asdf", description="test2",
            root_domain=m)
Esempio n. 38
0
    def test_add_AAAA_address_records(self):
        osu_block = "2620:105:F000:"
        create_reverse_domain('2.6.2.0', ip_type='6')

        self.create_ar(
            label='', domain=self.f_o_e, ip_str=(osu_block + ':4'),
            ip_type='6')
        self.create_ar(
            label='', domain=self.o_e, ip_str=(osu_block + ':1'), ip_type='6')
        self.create_ar(
            label='6ba-r', domain=self.o_e, ip_str=(osu_block + ':6'),
            ip_type='6')
        self.create_ar(
            label='6ba-r', domain=self.f_o_e, ip_str=(osu_block + ':7'),
            ip_type='6')
        self.create_ar(
            label='6foo', domain=self.f_o_e, ip_str=(osu_block + ':5'),
            ip_type='6')
        self.create_ar(
            label='6foo', domain=self.o_e, ip_str=(osu_block + ':3'),
            ip_type='6')
        self.create_ar(
            label='6ba3z', domain=self.o_e, ip_str=(osu_block + ':4'),
            ip_type='6')
        self.create_ar(
            label='6ba3z', domain=self.f_o_e, ip_str=(osu_block + ':6'),
            ip_type='6')
        self.create_ar(
            label='6foob1ar', domain=self.o_e, ip_str=(osu_block + ':5'),
            ip_type='6')
        self.create_ar(
            label='6foob1ar', domain=self.f_o_e, ip_str=(osu_block + ':8'),
            ip_type='6')
        self.create_ar(
            label='23412341253254243', domain=self.f_o_e,
            ip_str=(osu_block + ':8'), ip_type='6')
Esempio n. 39
0
 def test_remove_invalid_reverse_domain(self):
     rd1 = create_reverse_domain('130', ip_type='4')
     rd2 = create_reverse_domain('130.193', ip_type='4')
     rd3 = create_reverse_domain('130.193.8', ip_type='4')
     self.assertRaises(ValidationError, rd1.delete)
Esempio n. 40
0
    def setUp(self):
        super(SimpleTest, self).setUp()

        rd = create_reverse_domain('66', ip_type='4')
Esempio n. 41
0
    def setUp(self):
        super(V6StaticInterTests, self).setUp(ip_type='6')

        create_reverse_domain('0', ip_type='6')
        create_zone('1.ip6.arpa')
Esempio n. 42
0
    def setUp(self):
        super(V6StaticInterTests, self).setUp(ip_type='6')

        create_reverse_domain('0', ip_type='6')
        create_zone('1.ip6.arpa')
Esempio n. 43
0
    def setUp(self):
        super(SimpleTest, self).setUp()

        rd = create_reverse_domain('66', ip_type='4')
Esempio n. 44
0
 def test_remove_invalid_reverse_domain(self):
     rd1 = create_reverse_domain('130', ip_type='4')
     rd2 = create_reverse_domain('130.193', ip_type='4')
     rd3 = create_reverse_domain('130.193.8', ip_type='4')
     self.assertRaises(ValidationError, rd1.delete)