コード例 #1
0
ファイル: test_models.py プロジェクト: OSU-Net/cyder
    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')
コード例 #2
0
ファイル: test_models.py プロジェクト: murrown/cyder
    def setUp(self):
        super(NSTestsModels, self).setUp()

        self.r = Domain.objects.create(name="ru")
        self.f_r = Domain.objects.create(name="foo.ru")
        self.b_f_r = Domain.objects.create(name="bar.foo.ru")
        Domain.objects.create(name="asdf")

        for d in (self.r, self.f_r, self.b_f_r):
            self.ctnr.domains.add(d)

        create_zone('128.in-addr.arpa')

        self.s = System.objects.create(name='test_system', ctnr=self.ctnr)

        self.net1 = Network.objects.create(network_str='128.193.0.0/17')
        self.sr1 = Range.objects.create(
            network=self.net1, range_type=STATIC, start_str='128.193.99.2',
            end_str='128.193.99.14')
        self.sr2 = Range.objects.create(
            network=self.net1, range_type=STATIC, start_str='128.193.1.1',
            end_str='128.193.1.14')

        self.net2 = Network.objects.create(network_str='14.10.1.0/30')
        self.sr3 = Range.objects.create(
            network=self.net2, range_type=STATIC, start_str='14.10.1.1',
            end_str='14.10.1.2')

        for r in (self.sr1, self.sr2, self.sr3):
            self.ctnr.ranges.add(r)
コード例 #3
0
ファイル: basestatic.py プロジェクト: church29/cyder
    def setUp(self, ip_type='4'):
        super(BaseStaticTests, self).setUp()

        self.c = Domain.objects.create(name="ccc")
        self.f_c = Domain.objects.create(name="foo.ccc")
        self.ctnr.domains.add(self.c)
        self.ctnr.domains.add(self.f_c)
        self.n = System.objects.create(name='test_system')
        View.objects.get_or_create(name="private")

        if ip_type == '4':
            create_zone('10.in-addr.arpa')
            self.net = Network.objects.create(network_str='10.0.0.0/27')
            self.sr = Range.objects.create(
                network=self.net, range_type=STATIC, start_str='10.0.0.1',
                end_str='10.0.0.10')
            self.ctnr.ranges.add(self.sr)
        else:
            self.net = Network.objects.create(
                network_str='1000::/16', ip_type='6')
            self.sr = Range.objects.create(
                network=self.net, range_type=STATIC, ip_type='6',
                start_str='1000::1',
                end_str='1000:ffff:ffff:ffff:ffff:ffff:ffff:fffe')
            self.ctnr.ranges.add(self.sr)
コード例 #4
0
ファイル: test_dirty_soa.py プロジェクト: murrown/cyder
    def setUp(self):
        super(DirtySOATests, self).setUp()

        self.r1 = create_zone(name='10.in-addr.arpa')
        self.sr = self.r1.soa
        self.sr.dirty = False
        self.sr.save()

        Domain.objects.create(name='bgaz')
        self.dom = create_zone('azg.bgaz')
        self.soa = self.dom.soa
        self.soa.dirty = False
        self.soa.save()
        Domain.objects.create(name='com')
        Domain.objects.create(name='bar.com')
        create_zone('foo.bar.com')

        self.rdom = create_zone('123.in-addr.arpa')
        self.rsoa = self.r1.soa
        self.rsoa.dirty = False
        self.rsoa.save()

        self.ctnr.domains.add(self.dom, self.rdom)

        self.s = System.objects.create(name='test_system', ctnr=self.ctnr)

        self.net = Network.objects.create(network_str='10.2.3.0/30')
        self.range = Range.objects.create(
            network=self.net, range_type=STATIC, start_str='10.2.3.1',
            end_str='10.2.3.2')
        self.ctnr.ranges.add(self.range)
コード例 #5
0
ファイル: test_dns.py プロジェクト: OSU-Net/cyder
    def test_integration1(self):
        create_zone('wee.wee.mozilla.com')
        res, error = self.search("wee.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 1)
        self.assertEqual(len(res['DOMAIN']), 1)

        create_zone('wee1.wee.mozilla.com')
        res, error = self.search("wee1.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 1)
        self.assertEqual(len(res['DOMAIN']), 1)

        res, error = self.search("wee1.wee.mozilla.com OR "
                                 "wee.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 2)
        self.assertEqual(len(res['NS']), 2)
        self.assertEqual(len(res['DOMAIN']), 2)

        res, error = self.search("wee1.wee.mozilla.com type:SOA")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 0)
        self.assertEqual(len(res['DOMAIN']), 0)

        res, error = self.search(
            "wee1.wee.mozilla.com type:NS OR "
            "wee.wee.mozilla.com type:DOMAIN")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 0)
        self.assertEqual(len(res['NS']), 1)
        self.assertEqual(len(res['DOMAIN']), 1)
コード例 #6
0
ファイル: test_reverse.py プロジェクト: OSU-Net/cyder
    def test_remove_reverse_domain(self):
        create_zone('127.in-addr.arpa')
        rd1 = create_zone('193.127.in-addr.arpa')
        rd2 = create_zone('8.193.127.in-addr.arpa')

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

        rd2.soa.delete()
        rd2.nameserver_set.get().delete()
        rd2.delete()

        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)
コード例 #7
0
ファイル: test_dns.py プロジェクト: OSU-Net/cyder
    def test_integration5_ip(self):
        root_domain = create_zone('wee5.wee.mozilla.com')
        self.ctnr.domains.add(root_domain)
        create_zone('10.in-addr.arpa')
        res, error = self.search("10.in-addr.arpa OR "
                                 "wee5.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 2)
        self.assertEqual(len(res['NS']), 2)
        self.assertEqual(len(res['DOMAIN']), 2)
        self.create_network_range(
            network_str="10.0.0.0/24", start_str="10.0.0.1",
            end_str="10.0.0.2", range_type="st", ip_type='4',
            domain=root_domain)
        ptr = PTR.objects.create(
            ctnr=self.ctnr, fqdn="host1.wee.mozilla.com", ip_str="10.0.0.1",
            ip_type="4")
        addr = AddressRecord.objects.create(
            label="host1", ctnr=self.ctnr, domain=root_domain,
            ip_str="10.0.0.1", ip_type="4")

        res, error = self.search(ptr.ip_str)
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 1)
        self.assertEqual(len(res['A']), 1)

        res, error = self.search("10.0.0.2")
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 0)
        self.assertEqual(len(res['A']), 0)
コード例 #8
0
ファイル: test_dns.py プロジェクト: OSU-Net/cyder
    def test_integration4_ip_range(self):
        d = create_zone('wee3.wee.mozilla.com')
        Domain.objects.create(name='2.ip6.arpa')
        d2 = create_zone('1.2.ip6.arpa')
        self.ctnr.domains.add(d, d2)
        res, error = self.search("1.2.ip6.arpa")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 1)
        self.assertEqual(len(res['DOMAIN']), 1)

        self.create_network_range(
            network_str="2111:0::/32", start_str="2111:0::0",
            end_str="2111:0::1000", range_type="st", ip_type='6', domain=d)
        ptr = PTR.objects.create(
            ctnr=self.ctnr, fqdn="host1.wee.mozilla.com", ip_str="2111:0::",
            ip_type="6")

        res, error = self.search(ptr.ip_str)
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 1)
        self.assertEqual(len(res['A']), 0)

        res, error = self.search("2111:0:0::")
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 0)
        self.assertEqual(len(res['A']), 0)
コード例 #9
0
ファイル: test_reverse.py プロジェクト: OSU-Net/cyder
    def test_delegation_add_domain(self):
        create_zone('3.ip6.arpa')
        Domain.objects.create(name='4.3.ip6.arpa', delegated=True)

        self.assertRaises(
            ValidationError, Domain.objects.create, name='5.4.3.ip6.arpa',
            delegated=False)
コード例 #10
0
ファイル: test_reverse.py プロジェクト: OSU-Net/cyder
    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')
コード例 #11
0
ファイル: ipv4_tests.py プロジェクト: OSU-Net/cyder
    def setUp(self):
        self.ctnr = Ctnr.objects.create(name='abloobloobloo')
        self.d = Domain.objects.create(name="com")
        self.ctnr.domains.add(self.d)

        Domain.objects.create(name="arpa")
        Domain.objects.create(name="in-addr.arpa")
        create_zone('10.in-addr.arpa')

        self.s = Network.objects.create(network_str="10.0.0.0/16", ip_type='4')
        self.s1 = Network.objects.create(
            network_str="10.2.1.0/24", ip_type='4')
コード例 #12
0
ファイル: test_dns.py プロジェクト: OSU-Net/cyder
    def test_integration2(self):
        root_domain = create_zone('wee2.wee.mozilla.com')
        self.ctnr.domains.add(root_domain)
        res, error = self.search("wee2.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 1)
        self.assertEqual(len(res['DOMAIN']), 1)

        Domain.objects.create(name='1.ip6.arpa')
        create_zone('1.1.ip6.arpa')
        res, error = self.search("1.1.ip6.arpa")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 1)
        self.assertEqual(len(res['DOMAIN']), 1)

        self.create_network_range(
            network_str="1111:0::/32", start_str="1111:0::0",
            end_str="1111:0::1000", range_type="st", ip_type='6',
            domain=root_domain)

        ptr = PTR.objects.create(
            ctnr=self.ctnr, fqdn="host1.wee2.wee.mozilla.com", ip_str="1111::",
            ip_type="6")
        addr = AddressRecord.objects.create(
            label="host1", ctnr=self.ctnr, domain=root_domain, ip_str="11::",
            ip_type="6")
        res, error = self.search("host1.wee2.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['A']), 1)
        self.assertEqual(len(res['PTR']), 1)

        res, error = self.search("host1.wee2.wee.mozilla.com type:A")
        self.assertFalse(error)
        self.assertEqual(len(res['A']), 1)
        self.assertEqual(len(res['PTR']), 0)

        res, error = self.search("host1.wee2.wee.mozilla.com type:PTR")
        self.assertFalse(error)
        self.assertEqual(len(res['A']), 0)
        self.assertEqual(len(res['PTR']), 1)

        res, error = self.search("host1.wee2.wee.mozilla.com type:A "
                                 "type:PTR")
        self.assertFalse(error)
        self.assertEqual(len(res['A']), 0)
        self.assertEqual(len(res['PTR']), 0)
コード例 #13
0
ファイル: basic_tests.py プロジェクト: church29/cyder
    def test_delegation_add_domain(self):
        boom = create_zone('boom')
        bleh = Domain.objects.create(name='bleh.boom', delegated=True)

        self.assertRaises(
            ValidationError, Domain.objects.create,
            name='baa.bleh.boom', delegated=False)
コード例 #14
0
ファイル: test_auto_delete.py プロジェクト: OSU-Net/cyder
    def test_cleanup_cname(self):
        # Make sure CNAME record block
        c = Domain.objects.create(name='foo1')
        self.assertFalse(c.purgeable)
        f_c = create_zone('foo.foo1')
        self.ctnr.domains.add(f_c)
        self.assertEqual(f_c.name, 'foo.foo1')

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1").exists())
        self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1").exists())
        self.assertFalse(Domain.objects.filter(name="z.foo.foo1").exists())
        self.assertTrue(Domain.objects.filter(name="foo.foo1").exists())

        self.assertFalse(f_c.purgeable)
        fqdn = "cname.x.y.z.foo.foo1"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)

        cname = CNAME.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, target="foo")
        self.assertFalse(prune_tree(the_domain))
        cname.delete()

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1").exists())
        self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1").exists())
        self.assertFalse(Domain.objects.filter(name="z.foo.foo1").exists())
        fqdn = "bar.x.y.z.foo.poo"
        self.assertTrue(Domain.objects.filter(name="foo.foo1").exists())
コード例 #15
0
ファイル: test_full_name.py プロジェクト: OSU-Net/cyder
    def test_basic_add_remove8(self):
        # Make sure a record's label is changed to '' when a domain with the
        # same name as it's fqdn is created.
        Domain.objects.create(name='foo3')
        f_c = create_zone('foo.foo3')
        self.assertFalse(f_c.purgeable)

        fqdn = "www.x.y.z.foo.foo3"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        self.assertEqual('www', label)
        self.assertEqual('x.y.z.foo.foo3', the_domain.name)
        self.assertTrue(the_domain.pk)

        cname = CNAME.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, target="foo")
        fqdn = "*.www.x.y.z.foo.foo3"
        the_domain.save()
        label2, the_domain2 = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain2)
        cname = CNAME.objects.get(fqdn=cname.fqdn)
        self.assertEqual('', cname.label)
        self.assertEqual('www.x.y.z.foo.foo3', cname.domain.name)
        self.assertEqual('*', label2)
        self.assertEqual('www.x.y.z.foo.foo3', the_domain2.name)
コード例 #16
0
ファイル: test_full_name.py プロジェクト: OSU-Net/cyder
    def test_basic_add_remove3(self):
        # Make sure that if a domain is set to not purgeable the prune stops at
        # that domain when a record exists in a domain.
        Domain.objects.create(name='foo')
        f_c = create_zone('foo.foo')
        self.assertFalse(f_c.purgeable)

        fqdn = "bar.x.y.z.foo.foo"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)

        txt = TXT.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, txt_data="Nothing")

        self.assertTrue(the_domain.purgeable)
        # txt makes the domain un-purgeable.
        self.assertFalse(prune_tree(the_domain))
        txt.delete()
        # The tree should have pruned itself.

        # Make sure stuff was deleted.
        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.foo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.foo"))
        self.assertTrue(Domain.objects.filter(name="foo.foo"))
コード例 #17
0
ファイル: test_auto_update.py プロジェクト: OSU-Net/cyder
    def generic_check(self, obj, do_label=True, label_prefix=""):
        # Make sure all record types block
        f_c = create_zone('foo.foo22')
        self.ctnr.domains.add(f_c)
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        if do_label:
            # NS records don't like labels
            label = label_prefix + label
            obj.label = label
        obj.domain = the_domain
        obj.save()

        fqdn = "bar.x.y.xx.foo.foo22"
        label, new_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(new_domain)
        obj.domain = new_domain
        obj.save()

        # The original domain should have been deleted.
        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo22"))
        # Make sure no objects were harmed.
        self.assertTrue(obj.__class__.objects.get(pk=obj.pk))
        obj.delete()
        # The new domain should now have been deleted.
        self.assertFalse(Domain.objects.filter(name="x.y.xx.foo.foo22"))
コード例 #18
0
ファイル: tests.py プロジェクト: church29/cyder
    def create_data(self):
        Domain.objects.create(name='arpa')
        system = System.objects.create(name="TestSystem")

        Domain.objects.create(name='ip6.arpa')
        create_zone('2.ip6.arpa')
        net = Network.objects.create(network_str='2001::/16', ip_type='6')
        range = Range.objects.create(
            network=net, range_type='st', ip_type='6', start_str='2001::1',
            end_str='2001:ffff:ffff:ffff:ffff:ffff:ffff:fffe')

        return StaticInterface.objects.create(
            ctnr=self.ctnr, description='Test Static Interface', ttl=420,
            mac='11:22:33:44:55:00', system=system, label='stat',
            domain=self.domain, dhcp_enabled=False, dns_enabled=True,
            ip_str='2001:0db8:85a3:0000:0000:8a2e:0370:7344', ip_type='6')
コード例 #19
0
ファイル: tests.py プロジェクト: church29/cyder
    def create_data(self):
        Domain.objects.create(name='arpa')
        system = System.objects.create(name="TestSystem")

        Domain.objects.create(name='in-addr.arpa')
        create_zone('11.in-addr.arpa')
        net = Network.objects.create(
            network_str='11.12.14.0/8', ip_type='4')
        range = Range.objects.create(
            network=net, range_type='st', ip_type='4',
            start_str='11.12.14.253', end_str='11.12.14.254')

        return StaticInterface.objects.create(
            ctnr=self.ctnr, description='Test Static Interface', ttl=420,
            mac='11:22:33:44:55:00', system=system, label='stat',
            domain=self.domain, dhcp_enabled=False, dns_enabled=True,
            ip_str='11.12.14.253', ip_type='4')
コード例 #20
0
ファイル: tests.py プロジェクト: church29/cyder
    def setUp(self):
        self.ctnr = Ctnr.objects.create(name='abloobloobloo')

        self.o = Domain.objects.create(name="org")
        self.f_o = Domain.objects.create(name="foo.org")
        self.ctnr.domains.add(self.o, self.f_o)

        self.s = System.objects.create(name='foobar')

        Domain.objects.create(name="arpa")
        Domain.objects.create(name="in-addr.arpa")
        create_zone('10.in-addr.arpa')

        self.public = View.objects.create(name="public")
        self.private = View.objects.create(name="private")

        self.net = Network.objects.create(network_str='10.0.0.0/29')
        self.sr = Range.objects.create(
            network=self.net, range_type=STATIC, start_str='10.0.0.1',
            end_str='10.0.0.3')
        self.ctnr.ranges.add(self.sr)
コード例 #21
0
ファイル: tests.py プロジェクト: OSU-Net/cyder
    def create_data(self):
        Domain.objects.create(name="arpa")
        Domain.objects.create(name="ip6.arpa")
        create_zone("1.ip6.arpa")
        create_network_range(
            network_str="1000:2000::/32",
            start_str="1000:2000:3000::4000:5000:5000",
            end_str="1000:2000:3000::4000:5000:6000",
            range_type="st",
            ip_type="6",
            domain=self.domain,
            ctnr=self.ctnr,
        )

        return PTR.objects.create(
            ctnr=self.ctnr,
            description="PTR Record",
            ttl=420,
            fqdn=("ptr." + self.domain.name),
            ip_str="1000:2000:3000:0000:0000:4000:5000:6000",
            ip_type="6",
        )
コード例 #22
0
ファイル: test_auto_delete.py プロジェクト: church29/cyder
    def test_cleanup_intr(self):
        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo").exists())
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo").exists())
        self.assertFalse(Domain.objects.filter(name="z.foo.poo").exists())
        self.assertTrue(Domain.objects.filter(name="foo.poo").exists())

        create_zone('10.in-addr.arpa')

        fqdn = "bar.x.y.z.foo.poo"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        system = System.objects.create(name='foobar')
        addr = StaticInterface.objects.create(
            label=label, domain=the_domain, ip_type='4', ip_str="10.2.3.4",
            mac="00:11:22:33:44:55", system=system, ctnr=self.ctnr,)
        self.assertFalse(prune_tree(the_domain))
        addr.delete(**{'delete_system': False})

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo").exists())
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo").exists())
        self.assertFalse(Domain.objects.filter(name="z.foo.poo").exists())
        self.assertTrue(Domain.objects.filter(name="foo.poo").exists())
コード例 #23
0
ファイル: tests.py プロジェクト: OSU-Net/cyder
    def create_data(self):
        Domain.objects.create(name="arpa")
        Domain.objects.create(name="in-addr.arpa")
        create_zone("11.in-addr.arpa")
        create_network_range(
            network_str="11.1.2.0/24",
            start_str="11.1.2.1",
            end_str="11.1.2.127",
            range_type="st",
            ip_type="4",
            domain=self.domain,
            ctnr=self.ctnr,
        )

        return PTR.objects.create(
            ctnr=self.ctnr,
            description="PTR Record",
            ttl=420,
            fqdn=("ptr." + self.domain.name),
            ip_str="11.1.2.3",
            ip_type="4",
        )
コード例 #24
0
ファイル: basic_tests.py プロジェクト: church29/cyder
    def test_delegation(self):
        boom = create_zone('boom')
        bleh = Domain.objects.create(name='bleh.boom', delegated=True)
        self.ctnr.domains.add(bleh)

        # Creating objects in the domain should be disallowed.
        arec = AddressRecord(
            label="ns1", ctnr=self.ctnr, domain=bleh, ip_str="128.193.99.9",
            ip_type='4')
        self.assertRaises(ValidationError, arec.save)

        ns = Nameserver(ctnr=self.ctnr, domain=bleh, server="ns1." + bleh.name)
        self.assertRaises(ValidationError, ns.save)

        cn = CNAME(label="999asdf", ctnr=self.ctnr, domain=bleh,
                   target="asdf.asdf")
        self.assertRaises(ValidationError, cn.save)

        # Undelegate the domain.
        bleh.delegated = False
        bleh.save()

        # Add glue and NS record.
        arec.save()
        ns.save()

        # Re-delegate the domain.
        bleh.delegated = True
        bleh.save()

        # Creation should still be disallowed.
        self.assertRaises(
            ValidationError, AddressRecord.objects.create,
            label="ns2", ctnr=self.ctnr, domain=bleh, ip_str="128.193.99.9",
            ip_type='4')

        self.assertRaises(
            ValidationError, CNAME.objects.create,
            label="1000asdf", ctnr=self.ctnr, domain=bleh,
            target="asdf.asdf")

        # Editing should be allowed.
        arec = AddressRecord.objects.get(pk=arec.pk)
        arec.ip_str = "129.193.88.2"
        arec.save()

        # Adding new A records that have the same name as an NS should
        # be allowed.
        AddressRecord.objects.create(
            label="ns1", ctnr=self.ctnr, domain=bleh, ip_str="128.193.100.10",
            ip_type='4')
コード例 #25
0
ファイル: test_reverse.py プロジェクト: OSU-Net/cyder
    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)
コード例 #26
0
ファイル: test_full_name.py プロジェクト: OSU-Net/cyder
    def test_basic_add_remove6(self):
        # Make sure CNAME record block
        Domain.objects.create(name='foo1')
        f_c = create_zone('foo.foo1')
        f_c.save()
        self.assertFalse(f_c.purgeable)

        fqdn = "cname.x.y.z.foo.foo1"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)

        cname = CNAME.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, target="foo")
        self.assertFalse(prune_tree(the_domain))
        cname.delete()
コード例 #27
0
ファイル: test_full_name.py プロジェクト: OSU-Net/cyder
    def test_basic_add_remove7(self):
        # try a star record
        Domain.objects.create(name='foo2')
        f_c = create_zone('foo.foo2')
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "*.x.y.z.foo.foo2"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        self.assertEqual('*', label)

        cname = CNAME.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, target="foo")
        self.assertFalse(prune_tree(the_domain))
        cname.delete()
コード例 #28
0
ファイル: test_full_name.py プロジェクト: murrown/cyder
    def test_basic_add_remove6(self):
        # Make sure CNAME record block
        Domain.objects.create(name='foo1')
        f_c = create_zone('foo.foo1')
        f_c.save()
        self.assertFalse(f_c.purgeable)

        fqdn = "cname.x.y.z.foo.foo1"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)

        cname = CNAME.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, target="foo")
        self.assertFalse(prune_tree(the_domain))
        cname.delete()
コード例 #29
0
ファイル: test_full_name.py プロジェクト: murrown/cyder
    def test_basic_add_remove4(self):
        # Move a record down the tree testing prune's ability to not delete
        # stuff.
        Domain.objects.create(name='goo')
        f_c = create_zone('foo.goo')
        self.assertFalse(f_c.purgeable)

        fqdn = "bar.x.y.z.foo.goo"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        txt = TXT.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, txt_data="Nothing")

        self.assertTrue(the_domain.purgeable)

        # txt makes the domain un-purgeable.
        self.assertFalse(prune_tree(the_domain))
        the_next_domain = the_domain.master_domain
        txt.domain = the_next_domain
        self.ctnr.domains.add(the_next_domain)
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk).exists())
        # We should be able to delete now.
        self.assertTrue(prune_tree(the_domain))
        the_domain = the_next_domain

        # txt makes the domain un-purgeable. y.z.foo.com
        self.assertFalse(prune_tree(the_domain))
        the_next_domain = the_domain.master_domain
        txt.domain = the_next_domain
        self.ctnr.domains.add(the_next_domain)
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk))
        # We should be able to delete now.
        the_domain = the_next_domain

        # txt makes the domain un-purgeable. z.foo.com
        self.assertFalse(prune_tree(the_domain))
        the_next_domain = the_domain.master_domain
        txt.domain = the_next_domain
        self.ctnr.domains.add(the_next_domain)
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk).exists())
        # We should be able to delete now.
        the_domain = the_next_domain

        # txt makes the domain un-purgeable. foo.com
        self.assertFalse(prune_tree(the_domain))
コード例 #30
0
ファイル: test_full_name.py プロジェクト: OSU-Net/cyder
    def test_basic_add_remove4(self):
        # Move a record down the tree testing prune's ability to not delete
        # stuff.
        Domain.objects.create(name='goo')
        f_c = create_zone('foo.goo')
        self.assertFalse(f_c.purgeable)

        fqdn = "bar.x.y.z.foo.goo"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        txt = TXT.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, txt_data="Nothing")

        self.assertTrue(the_domain.purgeable)

        # txt makes the domain un-purgeable.
        self.assertFalse(prune_tree(the_domain))
        the_next_domain = the_domain.master_domain
        txt.domain = the_next_domain
        self.ctnr.domains.add(the_next_domain)
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk).exists())
        # We should be able to delete now.
        self.assertTrue(prune_tree(the_domain))
        the_domain = the_next_domain

        # txt makes the domain un-purgeable. y.z.foo.com
        self.assertFalse(prune_tree(the_domain))
        the_next_domain = the_domain.master_domain
        txt.domain = the_next_domain
        self.ctnr.domains.add(the_next_domain)
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk))
        # We should be able to delete now.
        the_domain = the_next_domain

        # txt makes the domain un-purgeable. z.foo.com
        self.assertFalse(prune_tree(the_domain))
        the_next_domain = the_domain.master_domain
        txt.domain = the_next_domain
        self.ctnr.domains.add(the_next_domain)
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk).exists())
        # We should be able to delete now.
        the_domain = the_next_domain

        # txt makes the domain un-purgeable. foo.com
        self.assertFalse(prune_tree(the_domain))
コード例 #31
0
ファイル: test_full_name.py プロジェクト: murrown/cyder
    def test_basic_add_remove9(self):
        # Make sure all record types block.
        Domain.objects.create(name='foo22')
        f_c = create_zone('foo.foo22')
        self.assertFalse(f_c.purgeable)

        fqdn = "y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        addr = AddressRecord.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, ip_type='4',
            ip_str="10.2.3.4")
        self.assertFalse(prune_tree(the_domain))

        new_domain = ensure_domain('y.z.foo.foo22')
        self.assertFalse(new_domain.purgeable)
コード例 #32
0
ファイル: test_models.py プロジェクト: murrown/cyder
    def test_bad_nameserver_soa_state_case_3_3(self):
        # This is Case 3 ... with PTRs
        root_domain = create_zone('14.in-addr.arpa')

        bad_root_domain = Domain.objects.create(name="10." + root_domain.name)
        cdomain = Domain.objects.create(name="1.10.14.in-addr.arpa")

        PTR.objects.create(
            fqdn=('eh.' + cdomain.name), ctnr=self.ctnr, ip_type="4",
            ip_str="14.10.1.1")

        # Now try to add the domain to the zone that has no NS records at its
        # root.
        self.assertRaises(
            ValidationError, SOA.objects.create,
            root_domain=bad_root_domain, contact="a", primary='b')
コード例 #33
0
ファイル: test_full_name.py プロジェクト: OSU-Net/cyder
    def test_basic_add_remove9(self):
        # Make sure all record types block.
        Domain.objects.create(name='foo22')
        f_c = create_zone('foo.foo22')
        self.assertFalse(f_c.purgeable)

        fqdn = "y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        addr = AddressRecord.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, ip_type='4',
            ip_str="10.2.3.4")
        self.assertFalse(prune_tree(the_domain))

        new_domain = ensure_domain('y.z.foo.foo22')
        self.assertFalse(new_domain.purgeable)
コード例 #34
0
    def test_bad_nameserver_soa_state_case_3_3(self):
        # This is Case 3 ... with PTRs
        root_domain = create_zone('14.in-addr.arpa')

        bad_root_domain = Domain.objects.create(name="10." + root_domain.name)
        cdomain = Domain.objects.create(name="1.10.14.in-addr.arpa")

        PTR.objects.create(
            fqdn=('eh.' + cdomain.name), ctnr=self.ctnr, ip_type="4",
            ip_str="14.10.1.1")

        # Now try to add the domain to the zone that has no NS records at its
        # root.
        self.assertRaises(
            ValidationError, SOA.objects.create,
            root_domain=bad_root_domain, contact="a", primary='b')
コード例 #35
0
    def test_basic_add_remove7(self):
        # try a star record
        Domain.objects.create(name='foo2')
        f_c = create_zone('foo.foo2')
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "*.x.y.z.foo.foo2"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        self.assertEqual('*', label)

        cname = CNAME.objects.create(label=label,
                                     ctnr=self.ctnr,
                                     domain=the_domain,
                                     target="foo")
        self.assertFalse(prune_tree(the_domain))
        cname.delete()
コード例 #36
0
ファイル: test_full_name.py プロジェクト: murrown/cyder
    def test_basic_add_remove5(self):
        # Make sure all record types block
        Domain.objects.create(name='foo22')
        f_c = create_zone('foo.foo22')
        self.assertFalse(f_c.purgeable)

        fqdn = "bar.x.y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)

        txt = TXT.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, txt_data="Nothing")
        self.assertFalse(prune_tree(the_domain))
        txt.delete()

        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        addr = AddressRecord.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, ip_type='4',
            ip_str="10.2.3.4")
        self.assertFalse(prune_tree(the_domain))
        addr.delete()

        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        mx = MX.objects.create(
            label=label, ctnr=self.ctnr, domain=the_domain, server="foo",
            priority=4)
        self.assertFalse(prune_tree(the_domain))
        mx.delete()

        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        ns = Nameserver.objects.create(
            ctnr=self.ctnr, domain=the_domain, server="asdfasffoo")
        self.assertFalse(prune_tree(the_domain))
        ns.delete()

        label, the_domain = ensure_label_domain(fqdn)
        self.ctnr.domains.add(the_domain)
        srv = SRV.objects.create(
            label='_' + label, ctnr=self.ctnr, domain=the_domain, target="foo",
            priority=4, weight=4, port=34)
        self.assertFalse(prune_tree(the_domain))
        srv.delete()
コード例 #37
0
    def test_bad_nameserver_soa_state_case_3_2(self):
        # This is Case 3 ... with PTRs
        root_domain = create_zone('14.in-addr.arpa')
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        root_domain.soa.delete()
        root_domain = Domain.objects.get(pk=root_domain.pk)
        self.assertIsNone(root_domain.soa)

        # At this point we should have a domain pointed at no SOA record with
        # no records attached to it. It also has no child domains.

        # Add a record to the domain.

        self.assertRaises(
            ValidationError, PTR.objects.create,
            ctnr=self.ctnr, fqdn="bloo.asdf", ip_str="14.10.1.1", ip_type="4")
コード例 #38
0
    def setUp(self):
        super(ReverseDomainTests, self).setUp()

        Domain.objects.create(name='com')
        Domain.objects.create(name='mozilla.com')
        self.domain = create_zone('foo.mozilla.com')
        self.ctnr.domains.add(self.domain)
        self.s = System.objects.create(name='mozilla.com')

        self.create_network_range(
            network_str="127.193.8.0/29", start_str="127.193.8.1",
            end_str="127.193.8.4", ip_type='4')
        self.create_network_range(
            network_str="2620:105::/32", start_str="2620:105:f000:8000::1",
            end_str="2620:105:f000:8000::1000", ip_type='6')
        self.create_network_range(
            network_str="2001:db8::/32", start_str="2001:db8:85a3::8000:0:0",
            end_str="2001:db8:85a3::9000:0:0", ip_type='6')
コード例 #39
0
ファイル: test_models.py プロジェクト: woakes070048/cyder
    def setUp(self):
        super(CNAMETests, self).setUp()

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

        create_zone('128.in-addr.arpa')

        self.ctnr2 = Ctnr.objects.create(name='test_ctnr2')

        self.g = create_zone('gz')
        self.c_g = create_zone('coo.gz')
        self.d = create_zone('dz')
        Domain.objects.create(name='cd')
        self.whatcd = create_zone('what.cd')

        for dom in (self.g, self.c_g, self.d, self.whatcd):
            self.ctnr.domains.add(dom)

        self.r1 = create_zone('10.in-addr.arpa')
        self.r1.save()

        self.s = System.objects.create(name='test_system', ctnr=self.ctnr)

        self.net1 = Network.objects.create(network_str='10.0.0.0/8')

        self.net2 = Network.objects.create(network_str='128.193.1.0/30')

        self.sr1 = Range.objects.create(network=self.net1,
                                        range_type=STATIC,
                                        start_str='10.0.0.1',
                                        end_str='10.0.0.3')

        self.sr2 = Range.objects.create(network=self.net1,
                                        range_type=STATIC,
                                        start_str='10.193.1.1',
                                        end_str='10.193.1.2')

        self.sr3 = Range.objects.create(network=self.net2,
                                        range_type=STATIC,
                                        start_str='128.193.1.1',
                                        end_str='128.193.1.2')

        for r in (self.sr1, self.sr2, self.sr3):
            self.ctnr.ranges.add(r)
コード例 #40
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)
コード例 #41
0
ファイル: test_dns.py プロジェクト: woakes070048/cyder
    def test_integration3_zone(self):
        root_domain = create_zone('wee3.wee.mozilla.com')
        self.ctnr.domains.add(root_domain)
        res, error = self.search("zone:wee3.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 1)
        self.assertEqual(len(res['NS']), 1)
        cn = CNAME.objects.create(label="host1",
                                  ctnr=self.ctnr,
                                  domain=root_domain,
                                  target="whop.whop")
        res, error = self.search("zone:wee3.wee.mozilla.com host1")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 0)
        self.assertEqual(len(res['NS']), 0)
        self.assertEqual(len(res['CNAME']), 1)

        res, error = self.search("zone:wee3.wee.mozilla.com " "type:CNAME")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 0)
        self.assertEqual(len(res['NS']), 0)
        self.assertEqual(len(res['CNAME']), 1)
コード例 #42
0
    def test_delegation(self):
        boom = create_zone('boom')
        bleh = Domain.objects.create(name='bleh.boom', delegated=True)
        self.ctnr.domains.add(bleh)

        # Creating objects in the domain should be disallowed.
        arec = AddressRecord(label="ns1",
                             ctnr=self.ctnr,
                             domain=bleh,
                             ip_str="128.193.99.9",
                             ip_type='4')
        self.assertRaises(ValidationError, arec.save)

        ns = Nameserver(ctnr=self.ctnr, domain=bleh, server="ns1." + bleh.name)
        self.assertRaises(ValidationError, ns.save)

        cn = CNAME(label="999asdf",
                   ctnr=self.ctnr,
                   domain=bleh,
                   target="asdf.asdf")
        self.assertRaises(ValidationError, cn.save)

        # Undelegate the domain.
        bleh.delegated = False
        bleh.save()

        # Add glue and NS record.
        arec.save()
        ns.save()

        # Re-delegate the domain.
        bleh.delegated = True
        bleh.save()

        # Creation should still be disallowed.
        self.assertRaises(ValidationError,
                          AddressRecord.objects.create,
                          label="ns2",
                          ctnr=self.ctnr,
                          domain=bleh,
                          ip_str="128.193.99.9",
                          ip_type='4')

        self.assertRaises(ValidationError,
                          CNAME.objects.create,
                          label="1000asdf",
                          ctnr=self.ctnr,
                          domain=bleh,
                          target="asdf.asdf")

        # Editing should be allowed.
        arec = AddressRecord.objects.get(pk=arec.pk)
        arec.ip_str = "129.193.88.2"
        arec.save()

        # Adding new A records that have the same name as an NS should
        # be allowed.
        AddressRecord.objects.create(label="ns1",
                                     ctnr=self.ctnr,
                                     domain=bleh,
                                     ip_str="128.193.100.10",
                                     ip_type='4')
コード例 #43
0
    def setUp(self):
        super(V6StaticInterTests, self).setUp(ip_type='6')

        create_reverse_domain('0', ip_type='6')
        create_zone('1.ip6.arpa')
コード例 #44
0
 def create_zone(self, name):
     domain = create_zone(name)
     self.ctnr.domains.add(domain)
     return domain