1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Integration Testing framework (#46)

* integration test started

* details

* More tests.

* idn tests and punycode (not tested fully because I'm on an aiplane)

* test for dual provider compatibility

* readme for tests

* vendor idna

* fix casing
This commit is contained in:
Craig Peterson
2017-03-16 22:42:53 -07:00
committed by GitHub
parent 0906f5c383
commit 101916a6e4
12 changed files with 547 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/StackExchange/dnscontrol/transform"
"github.com/miekg/dns"
"golang.org/x/net/idna"
)
const DefaultTTL = uint32(300)
@@ -164,6 +165,32 @@ func (r *RecordConfig) Copy() (*RecordConfig, error) {
return newR, err
}
//Punycode will convert all records to punycode format.
//It will encode:
//- Name
//- NameFQDN
//- Target (CNAME and MX only)
func (dc *DomainConfig) Punycode() error {
var err error
for _, rec := range dc.Records {
rec.Name, err = idna.ToASCII(rec.Name)
if err != nil {
return err
}
rec.NameFQDN, err = idna.ToASCII(rec.NameFQDN)
if err != nil {
return err
}
if rec.Type == "MX" || rec.Type == "CNAME" {
rec.Target, err = idna.ToASCII(rec.Target)
if err != nil {
return err
}
}
}
return nil
}
func copyObj(input interface{}, output interface{}) error {
buf := &bytes.Buffer{}
enc := gob.NewEncoder(buf)