def test_delegation(self):
        name = "boom"
        dom = Domain(name=name, delegated=True)
        dom.save()

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

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

        cn = CNAME(label="999asdf", domain=dom, target="asdf.asdf")
        self.assertRaises(ValidationError, cn.full_clean)

        # Undelegate (unlock) the domain.
        dom.delegated = False
        dom.save()

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

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

        # Creation should still be locked
        arec1 = AddressRecord(label="ns2",
                              domain=dom,
                              ip_str="128.193.99.9",
                              ip_type='4')
        self.assertRaises(ValidationError, arec1.save)

        cn1 = CNAME(label="1000asdf", domain=dom, target="asdf.asdf")
        self.assertRaises(ValidationError, cn1.full_clean)

        # 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.
        arec1 = AddressRecord(label="ns1",
                              domain=dom,
                              ip_str="128.193.100.10",
                              ip_type='4')
        arec1.save()
Beispiel #2
0
    def test_delegation(self):
        name = "boom"
        dom = Domain(name=name, delegated=True)
        dom.save()

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

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

        cn = CNAME(label="999asdf", domain=dom, target="asdf.asdf")
        self.assertRaises(ValidationError, cn.full_clean)

        # Undelegate (unlock) the domain.
        dom.delegated = False
        dom.save()

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

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

        # Creation should still be locked
        arec1 = AddressRecord(
            label="ns2", domain=dom, ip_str="128.193.99.9", ip_type='4')
        self.assertRaises(ValidationError, arec1.save)

        cn1 = CNAME(label="1000asdf", domain=dom, target="asdf.asdf")
        self.assertRaises(ValidationError, cn1.full_clean)

        # 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.
        arec1 = AddressRecord(label="ns1", domain=dom, ip_str="128.193.100.10",
                              ip_type='4')
        arec1.save()
Beispiel #3
0
    def test_delegation_block(self):
        s, _ = SOA.objects.get_or_create(primary="foo", contact="Foo",
                                         description="foo")
        c = Domain(name='com')
        c.soa = s
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.com')
        f_c.delegated = True
        f_c.save()
        self.assertFalse(f_c.purgeable)
        self.assertTrue(f_c.delegated)

        fqdn = "z.baz.foo.com"
        self.assertRaises(ValidationError, ensure_label_domain, fqdn)