示例#1
0
    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
        c = Domain(name='foo')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.foo')
        s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
                                         comment="foo.foo")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo"
        label, the_domain = ensure_label_domain(fqdn)
        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()

        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"))
示例#2
0
 def do_generic_add(self, data):
     txt = TXT(**data)
     txt.__repr__()
     txt.save()
     self.assertTrue(txt.details())
     self.assertTrue(txt.get_detail_url())
     self.assertTrue(txt.get_update_url())
     self.assertTrue(txt.get_delete_url())
     rtxt = TXT.objects.filter(**data)
     self.assertTrue(len(rtxt) == 1)
     return txt
示例#3
0
文件: tests.py 项目: ngokevin/cyder
 def do_generic_add(self, data ):
     txt = TXT( **data )
     txt.__repr__()
     txt.save()
     self.assertTrue(txt.details())
     self.assertTrue(txt.get_absolute_url())
     self.assertTrue(txt.get_edit_url())
     self.assertTrue(txt.get_delete_url())
     rtxt = TXT.objects.filter( **data )
     self.assertTrue( len(rtxt) == 1 )
     return txt
示例#4
0
    def test_domain_records_perms(self):
        """
        Test common domain record perms (cname, mx, txt, srv, ns)
        """
        self.setup_request()

        perm_table = {
            'cyder_admin': ['all'],
            'admin': ['all'],
            'user': ['all'],
            'guest': [cy.ACTION_VIEW],
        }

        # Initialize objs into ctnrs.
        domain = Domain(id=None, name='foo')
        domain.save()
        self.ctnr_admin.domains.add(domain)
        self.ctnr_user.domains.add(domain)
        self.ctnr_guest.domains.add(domain)
        self.save_all_ctnrs()
        domain_records = []
        domain_records.append(AddressRecord(domain=domain))
        domain_records.append(CNAME(domain=domain))
        domain_records.append(MX(domain=domain))
        domain_records.append(SRV(domain=domain))
        domain_records.append(TXT(domain=domain))
        domain_records.append(Nameserver(domain=domain))

        for obj in domain_records:
            self.check_perms_each_user(obj, perm_table)
示例#5
0
    def test_basic_add_remove5(self):
        # Make sure all record types block
        c = Domain(name='foo22')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.foo22')
        s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
                                         comment="foo.foo22")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)

        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()
        self.assertFalse(prune_tree(the_domain))
        txt.delete()

        label, the_domain = ensure_label_domain(fqdn)
        addr = AddressRecord(label=label, domain=the_domain,
                             ip_type='4', ip_str="10.2.3.4")
        addr.save()
        self.assertFalse(prune_tree(the_domain))
        addr.delete()

        label, the_domain = ensure_label_domain(fqdn)
        mx = MX(label=label, domain=the_domain, server="foo", priority=4)
        mx.save()
        self.assertFalse(prune_tree(the_domain))
        mx.delete()

        label, the_domain = ensure_label_domain(fqdn)
        ns = Nameserver(domain=the_domain, server="asdfasffoo")
        ns.save()
        self.assertFalse(prune_tree(the_domain))
        ns.delete()

        label, the_domain = ensure_label_domain(fqdn)
        srv = SRV(
            label='_' + label, domain=the_domain, target="foo", priority=4,
            weight=4, port=34)
        srv.save()
        self.assertFalse(prune_tree(the_domain))
        srv.delete()
示例#6
0
    def test_cleanup_txt(self):
        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.poo"))
        self.assertTrue(Domain.objects.filter(name="foo.poo"))

        self.assertFalse(self.f_c.purgeable)
        fqdn = "bar.x.y.z.foo.poo"
        label, the_domain = ensure_label_domain(fqdn)

        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()
        self.assertFalse(prune_tree(the_domain))
        txt.delete()

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.poo"))
        self.assertTrue(Domain.objects.filter(name="foo.poo"))
示例#7
0
 def do_generic_add(self, data):
     txt = TXT(**data)
     txt.__repr__()
     txt.save()
     rtxt = TXT.objects.filter(**data)
     self.assertTrue(len(rtxt) == 1)
     return txt
示例#8
0
    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
        c = Domain(name='foo')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.foo')
        s, _ = SOA.objects.get_or_create(primary="foo",
                                         contact="foo",
                                         comment="foo.foo")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo"
        label, the_domain = ensure_label_domain(fqdn)
        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()

        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"))
示例#9
0
    def test_txt_cname_exists(self):
        label = "testyfoo"
        data = "wat"
        dom, _ = Domain.objects.get_or_create(name="cd")
        dom, _ = Domain.objects.get_or_create(name="what.cd")

        cn, _ = CNAME.objects.get_or_create(label=label,
                                            domain=dom,
                                            target=data)
        cn.full_clean()
        cn.save()

        rec = TXT(label=label, domain=dom, txt_data="asdf1")

        self.assertRaises(ValidationError, rec.save)
示例#10
0
    def test_basic_add_remove5(self):
        # Make sure all record types block
        c = Domain(name='foo22')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.foo22')
        s, _ = SOA.objects.get_or_create(primary="foo",
                                         contact="foo",
                                         comment="foo.foo22")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)

        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()
        self.assertFalse(prune_tree(the_domain))
        txt.delete()

        label, the_domain = ensure_label_domain(fqdn)
        addr = AddressRecord(label=label,
                             domain=the_domain,
                             ip_type='4',
                             ip_str="10.2.3.4")
        addr.save()
        self.assertFalse(prune_tree(the_domain))
        addr.delete()

        label, the_domain = ensure_label_domain(fqdn)
        mx = MX(label=label, domain=the_domain, server="foo", priority=4)
        mx.save()
        self.assertFalse(prune_tree(the_domain))
        mx.delete()

        label, the_domain = ensure_label_domain(fqdn)
        ns = Nameserver(domain=the_domain, server="asdfasffoo")
        ns.save()
        self.assertFalse(prune_tree(the_domain))
        ns.delete()

        label, the_domain = ensure_label_domain(fqdn)
        srv = SRV(label='_' + label,
                  domain=the_domain,
                  target="foo",
                  priority=4,
                  weight=4,
                  port=34)
        srv.save()
        self.assertFalse(prune_tree(the_domain))
        srv.delete()
示例#11
0
def migrate_TXT(zone, root_domain, soa, views):
    for (name, ttl, rdata) in zone.iterate_rdatas('TXT'):
        name = name.to_text().strip('.')
        print str(name) + " TXT " + str(rdata)
        exists_domain = Domain.objects.filter(name=name)
        if exists_domain:
            label = ''
            domain = exists_domain[0]
        else:
            label = name.split('.')[0]
            domain_name = name.split('.')[1:]
            domain = ensure_domain('.'.join(domain_name), force=True)
        data = rdata.to_text().strip('"')

        if not TXT.objects.filter(label=label, domain=domain,
                                  txt_data=data).exists():
            txt = TXT(label=label, domain=domain, txt_data=data)
            txt.full_clean()
            txt.save()
            for view in views:
                txt.views.add(view)
                txt.save()
示例#12
0
def migrate_TXT(zone, root_domain, soa, views):
    for (name, ttl, rdata) in zone.iterate_rdatas('TXT'):
        name = name.to_text().strip('.')
        print str(name) + " TXT " + str(rdata)
        exists_domain = Domain.objects.filter(name=name)
        if exists_domain:
            label = ''
            domain = exists_domain[0]
        else:
            label = name.split('.')[0]
            domain_name = name.split('.')[1:]
            domain = ensure_domain('.'.join(domain_name), force=True)
        data = rdata.to_text().strip('"')

        if not TXT.objects.filter(label=label, domain=domain,
                                  txt_data=data).exists():
            txt = TXT(label=label, domain=domain, txt_data=data)
            txt.full_clean()
            txt.save()
            for view in views:
                txt.views.add(view)
                txt.save()
示例#13
0
    def test_cleanup_txt(self):
        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.poo"))
        self.assertTrue(Domain.objects.filter(name="foo.poo"))

        self.assertFalse(self.f_c.purgeable)
        fqdn = "bar.x.y.z.foo.poo"
        label, the_domain = ensure_label_domain(fqdn)

        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()
        self.assertFalse(prune_tree(the_domain))
        txt.delete()

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.poo"))
        self.assertTrue(Domain.objects.filter(name="foo.poo"))
示例#14
0
文件: full_name.py 项目: jirwin/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
        f_c = create_fake_zone("foo.foo", suffix="")
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo"
        label, the_domain = ensure_label_domain(fqdn)
        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()

        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"))
示例#15
0
文件: full_name.py 项目: jirwin/cyder
    def test_basic_add_remove5(self):
        # Make sure all record types block
        f_c = create_fake_zone("foo.foo22", suffix="")
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)

        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()
        self.assertFalse(prune_tree(the_domain))
        txt.delete()

        label, the_domain = ensure_label_domain(fqdn)
        addr = AddressRecord(label=label, domain=the_domain,
                             ip_type='4', ip_str="10.2.3.4")
        addr.save()
        self.assertFalse(prune_tree(the_domain))
        addr.delete()

        label, the_domain = ensure_label_domain(fqdn)
        mx = MX(label=label, domain=the_domain, server="foo", priority=4)
        mx.save()
        self.assertFalse(prune_tree(the_domain))
        mx.delete()

        label, the_domain = ensure_label_domain(fqdn)
        ns = Nameserver(domain=the_domain, server="asdfasffoo")
        ns.save()
        self.assertFalse(prune_tree(the_domain))
        ns.delete()

        label, the_domain = ensure_label_domain(fqdn)
        srv = SRV(
            label='_' + label, domain=the_domain, target="foo", priority=4,
            weight=4, port=34)
        srv.save()
        self.assertFalse(prune_tree(the_domain))
        srv.delete()
示例#16
0
    for (name, ttl, rdata) in zone.iterate_rdatas('TXT'):
        name = name.to_text().strip('.')
        print str(name) + " TXT " + str(rdata)
        exists_domain = Domain.objects.filter(name=name)
        if exists_domain:
            label = ''
            domain = exists_domain[0]
        else:
            label = name.split('.')[0]
            domain_name = name.split('.')[1:]
            domain = ensure_domain('.'.join(domain_name))
        data = rdata.to_text().strip('"')

        if not TXT.objects.filter(label=label, domain=domain,
                                  txt_data=data).exists():
            txt = TXT(label=label, domain=domain, txt_data=data)
            txt.full_clean()
            txt.save()
            if views:
                for view in views:
                    txt.views.add(view)
                    txt.save()

    for (name, ttl, rdata) in zone.iterate_rdatas('SSHFP'):
        name = name.to_text().strip('.')
        pdb.set_trace()
        print str(name) + " SSHFP " + str(rdata)

    for (name, ttl, rdata) in zone.iterate_rdatas('SRV'):
        target = rdata.target.to_text().strip('.')
        if target == "":
示例#17
0
文件: api.py 项目: Ziaunys/chili
 class Meta:
     always_return_data = True
     queryset = TXT.objects.all()
     fields = TXT.get_api_fields() + ['domain', 'views']
     authorization = Authorization()
     allowed_methods = allowed_methods
示例#18
0
    for (name, ttl, rdata) in zone.iterate_rdatas('TXT'):
        name = name.to_text().strip('.')
        print str(name) + " TXT " + str(rdata)
        exists_domain = Domain.objects.filter(name=name)
        if exists_domain:
            label = ''
            domain = exists_domain[0]
        else:
            label = name.split('.')[0]
            domain_name = name.split('.')[1:]
            domain = ensure_domain('.'.join(domain_name))
        data = rdata.to_text().strip('"')

        if not TXT.objects.filter(label=label, domain=domain,
                                  txt_data=data).exists():
            txt = TXT(label=label, domain=domain,
                      txt_data=data)
            txt.full_clean()
            txt.save()
            if views:
                for view in views:
                    txt.views.add(view)
                    txt.save()

    for (name, ttl, rdata) in zone.iterate_rdatas('SSHFP'):
        name = name.to_text().strip('.')
        pdb.set_trace()
        print str(name) + " SSHFP " + str(rdata)

    for (name, ttl, rdata) in zone.iterate_rdatas('SRV'):
        target = rdata.target.to_text().strip('.')
        if target == "":
示例#19
0
文件: full_name.py 项目: jirwin/cyder
    def test_basic_add_remove4(self):
        # Move a record down the tree testing prune's ability to not delete
        # stuff.
        f_c = create_fake_zone("foo.goo", suffix="")
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.goo"
        label, the_domain = ensure_label_domain(fqdn)
        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()

        self.assertTrue(the_domain.purgeable)

        # txt makes the domain un-purgeable.
        self.assertFalse(prune_tree(the_domain))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_domain
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk))
        # 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))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_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))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_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. foo.com
        self.assertFalse(prune_tree(the_domain))
示例#20
0
 def test_txt_update(self):
     txt = TXT(txt_data="Nthing", ctnr=self.ctnr)
     self.generic_check(txt)
示例#21
0
    def test_basic_add_remove4(self):
        # Move a record down the tree testing prune's ability to not delete
        # stuff.
        c = Domain(name='goo')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.goo')
        s, _ = SOA.objects.get_or_create(primary="foo",
                                         contact="foo",
                                         comment="foo.goo")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.goo"
        label, the_domain = ensure_label_domain(fqdn)
        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()

        self.assertTrue(the_domain.purgeable)

        # txt makes the domain un-purgeable.
        self.assertFalse(prune_tree(the_domain))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_domain
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk))
        # 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))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_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))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_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. foo.com
        self.assertFalse(prune_tree(the_domain))
示例#22
0
    def test_basic_add_remove4(self):
        # Move a record down the tree testing prune's ability to not delete
        # stuff.
        c = Domain(name='goo')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.goo')
        s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
                                         comment="foo.goo")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.goo"
        label, the_domain = ensure_label_domain(fqdn)
        txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
        txt.save()

        self.assertTrue(the_domain.purgeable)

        # txt makes the domain un-purgeable.
        self.assertFalse(prune_tree(the_domain))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_domain
        txt.save()
        self.assertFalse(Domain.objects.filter(pk=the_domain.pk))
        # 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))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_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))
        txt.domain = the_domain.master_domain
        the_next_domain = the_domain.master_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. foo.com
        self.assertFalse(prune_tree(the_domain))