Esempio n. 1
0
    def parse(self, name: str, data: str, ttl: int) -> DNSRecordBase:
        from pypdnsrest.dnsrecords import DNSMxRecord
        from pypdnsrest.dnsrecords import DNSMxRecordData

        tmp = data.split(" ")
        d = DNSMxRecordData(priority=int(tmp[0]), server=tmp[1])
        rec = DNSMxRecord(name, timedelta(seconds=ttl))
        rec.set_data(d)
        return rec
Esempio n. 2
0
    def test_add_mx_record(self):
        from pypdnsrest.dnsrecords import DNSMxRecord
        from pypdnsrest.dnsrecords import DNSMxRecordData

        mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), 10)

        rec = DNSMxRecord(self.zone)
        rec.set_data(mxdata)

        z = DNSZone()
        self.assertTrue(z.add_record(rec))
Esempio n. 3
0
    def test_record(self):
        mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), 10)

        rec = DNSMxRecord(self.zone)
        self.assertTrue(rec.set_data(mxdata))
Esempio n. 4
0
    def test_invalid_priority_type(self):
        mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), u"invalid")

        rec = DNSMxRecord(self.zone)
        with self.assertRaises(InvalidDNSRecordException) as context:
            rec.set_data(mxdata)
Esempio n. 5
0
    def test_invalid_server(self):
        mxdata = DNSMxRecordData(u"invalid", 10)

        rec = DNSMxRecord(self.zone)
        with self.assertRaises(InvalidDNSRecordException) as context:
            rec.set_data(mxdata)
Esempio n. 6
0
    def test_record_wrong_priority(self):
        mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), -1)

        rec = DNSMxRecord(self.zone)
        with self.assertRaises(InvalidDNSRecordException) as context:
            rec.set_data(mxdata)
Esempio n. 7
0
    def test_record2(self):
        mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), 10,
                                 timedelta(hours=1))

        rec = DNSMxRecord(self.zone)
        self.assertTrue(rec.set_data(mxdata))