Example #1
0
    def test_invalid_update_to_existing(self):
        rec1 = AddressRecord(label='bar', domain=self.z_o_e,
                             ip_str="128.193.40.1", ip_type='4')
        rec2 = AddressRecord(label='bar', domain=self.z_o_e,
                             ip_str="128.193.40.2", ip_type='4')
        rec3 = AddressRecord(label='foo', domain=self.z_o_e,
                             ip_str="128.193.40.1", ip_type='4')
        rec3.save()
        rec2.save()
        rec1.save()

        rec1.label = "foo"
        self.assertRaises(ValidationError, rec1.save)

        rec3.label = "bar"
        self.assertRaises(ValidationError, rec3.save)

        osu_block = "633:105:F000:"
        rec1 = AddressRecord(label='bar', domain=self.z_o_e,
                             ip_str=osu_block + ":1", ip_type='6')
        rec2 = AddressRecord(label='bar', domain=self.z_o_e,
                             ip_str=osu_block + ":2", ip_type='6')
        rec3 = AddressRecord(label='foo', domain=self.z_o_e,
                             ip_str=osu_block + ":1", ip_type='6')
        rec1.save()
        rec2.save()
        rec3.save()

        rec2.ip_str = osu_block + ":1"
        self.assertRaises(ValidationError, rec2.save)

        rec3.label = 'bar'
        self.assertRaises(ValidationError, rec3.save)
Example #2
0
    def test_no_update_when_glue(self):
        """A record shouldn't update it's label or domain when it is a glue record"""
        label = 'ns99'
        glue = AddressRecord(label=label,
                             domain=self.o_e,
                             ip_str='128.193.1.10',
                             ip_type='4')
        glue.save()

        server = "%s.%s" % (label, self.o_e)
        ns = Nameserver(domain=self.o_e, server=server)
        ns.save()
        self.assertTrue(ns.glue == glue)

        # Shouldn't be able to edit label or domain.
        glue.label = "ns100"
        self.assertRaises(ValidationError, glue.save)
        glue.domain = self.m_o_e
        self.assertRaises(ValidationError, glue.save)

        glue = AddressRecord.objects.get(pk=glue.pk)
        glue.label = "ns101"
        glue.domain = self.e
        self.assertRaises(ValidationError, glue.save)

        # Ip can change.
        glue = AddressRecord.objects.get(pk=glue.pk)
        glue.ip_str = "192.192.12.12"
        glue.save()
Example #3
0
    def test_no_update_when_glue(self):
        """A record shouldn't update it's label or domain when it is a glue record"""
        label = 'ns99'
        glue = AddressRecord(label=label, domain=self.o_e,
                             ip_str='128.193.1.10', ip_type='4')
        glue.save()

        server = "%s.%s" % (label, self.o_e)
        ns = Nameserver(domain=self.o_e, server=server)
        ns.save()
        self.assertTrue(ns.glue == glue)

        # Shouldn't be able to edit label or domain.
        glue.label = "ns100"
        self.assertRaises(ValidationError, glue.save)
        glue.domain = self.m_o_e
        self.assertRaises(ValidationError, glue.save)

        glue = AddressRecord.objects.get(pk=glue.pk)
        glue.label = "ns101"
        glue.domain = self.e
        self.assertRaises(ValidationError, glue.save)

        # Ip can change.
        glue = AddressRecord.objects.get(pk=glue.pk)
        glue.ip_str = "192.192.12.12"
        glue.save()
Example #4
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 allows.
        arec1 = AddressRecord(label="ns1",
                              domain=dom,
                              ip_str="128.193.100.10",
                              ip_type='4')
        arec1.save()
Example #5
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')
Example #6
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(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')
Example #7
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 allows.
        arec1 = AddressRecord(
            label="ns1", domain=dom, ip_str="128.193.100.10", ip_type='4')
        arec1.save()
Example #8
0
    def test_invalid_update_to_existing(self):
        rec1 = AddressRecord(label='bar',
                             domain=self.z_o_e,
                             ip_str="128.193.40.1",
                             ip_type='4')
        rec2 = AddressRecord(label='bar',
                             domain=self.z_o_e,
                             ip_str="128.193.40.2",
                             ip_type='4')
        rec3 = AddressRecord(label='foo',
                             domain=self.z_o_e,
                             ip_str="128.193.40.1",
                             ip_type='4')
        rec3.save()
        rec2.save()
        rec1.save()

        rec1.label = "foo"
        self.assertRaises(ValidationError, rec1.save)

        rec3.label = "bar"
        self.assertRaises(ValidationError, rec3.save)

        osu_block = "633:105:F000:"
        rec1 = AddressRecord(label='bar',
                             domain=self.z_o_e,
                             ip_str=osu_block + ":1",
                             ip_type='6')
        rec2 = AddressRecord(label='bar',
                             domain=self.z_o_e,
                             ip_str=osu_block + ":2",
                             ip_type='6')
        rec3 = AddressRecord(label='foo',
                             domain=self.z_o_e,
                             ip_str=osu_block + ":1",
                             ip_type='6')
        rec1.save()
        rec2.save()
        rec3.save()

        rec2.ip_str = osu_block + ":1"
        self.assertRaises(ValidationError, rec2.save)

        rec3.label = 'bar'
        self.assertRaises(ValidationError, rec3.save)