Пример #1
0
    def test_add_a_record(self):
        from pypdnsrest.dnsrecords import DNSARecord
        from ipaddress import IPv4Address

        z = DNSZone()

        rec = DNSARecord(self.zone)
        rec.set_data(IPv4Address(u"192.168.0.1"))
        self.assertTrue(z.add_record(rec))
Пример #2
0
    def test_delete_record(self):
        from ipaddress import IPv4Address
        from pypdnsrest.dnsrecords import DNSARecord

        rec = DNSARecord(self.zone)
        rec.set_data(IPv4Address(u"192.168.0.1"))

        self.api.add_record(self.zone, rec)
        self.assertTrue(self.api.del_record(self.zone, rec))
Пример #3
0
    def test_valid(self):
        z = DNSZone()

        # Add SOA
        from pypdnsrest.dnsrecords import DNSSoaRecordData
        from pypdnsrest.dnsrecords import DNSSoaRecord

        soadata = DNSSoaRecordData(u"ns1.{0}".format(self.zone),
                                   u"admin.{0}".format(self.zone), 1)
        rec = DNSSoaRecord(self.zone)
        rec.set_data(soadata)
        z.add_record(rec)

        # Add NS
        from pypdnsrest.dnsrecords import DNSNsRecord
        rec = DNSNsRecord(self.zone)
        rec.set_data(u"ns1.{0}".format(self.zone))
        z.add_record(rec)

        rec = DNSNsRecord(self.zone)
        rec.set_data(u"ns2.{0}".format(self.zone))
        z.add_record(rec)

        # Add A
        from pypdnsrest.dnsrecords import DNSARecord
        from ipaddress import IPv4Address

        rec = DNSARecord(self.zone)
        rec.set_data(IPv4Address(u"192.168.0.1"))
        z.add_record(rec)

        self.assertTrue(z.validate())
Пример #4
0
    # Add NS records
    from pypdnsrest.dnsrecords import DNSNsRecord

    rec = DNSNsRecord(zone)
    rec.set_data("ns1.{0}".format(zone))
    api.add_record(zone, rec)

    rec = DNSNsRecord(zone)
    rec.set_data("ns2.{0}".format(zone))
    api.add_record(zone, rec)

    # Add A records
    from ipaddress import IPv4Address
    from pypdnsrest.dnsrecords import DNSARecord

    rec = DNSARecord(zone)
    rec.set_data(IPv4Address("192.168.0.1"))
    api.add_record(zone, rec)

    rec = DNSARecord("ns1.{0}".format(zone))
    rec.set_data(IPv4Address("192.168.0.1"))
    api.add_record(zone, rec)

    rec = DNSARecord("ns2.{0}".format(zone))
    rec.set_data(IPv4Address("192.168.0.1"))
    api.add_record(zone, rec)

    # Add PTR record
    from pypdnsrest.dnsrecords import DNSPtrRecord

    rec = DNSPtrRecord(zone)
Пример #5
0
 def test_record(self):
     rec = DNSARecord(self.zone)
     self.assertTrue(rec.set_data(IPv4Address(u"192.168.0.1")))
Пример #6
0
 def test_record_invalid(self):
     rec = DNSARecord(self.zone)
     with self.assertRaises(InvalidDNSRecordException) as context:
         rec.set_data(int(1))
Пример #7
0
 def parse(self, name: str, data: str, ttl: int) -> DNSRecordBase:
     from ipaddress import IPv4Address
     from pypdnsrest.dnsrecords import DNSARecord
     rec = DNSARecord(name, timedelta(seconds=ttl))
     rec.set_data(IPv4Address(data))
     return rec
Пример #8
0
 def test_delete_record_invalid2(self):
     from pypdnsrest.dnsrecords import DNSARecord
     rec = DNSARecord(self.zone)
     with self.assertRaises(InvalidDNSRecordException) as context:
         self.api.del_record(self.zone, rec)