From 2d51cd57ed46a775f9b9504a919273d89a75598a Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 20 Nov 2017 08:53:44 -0500 Subject: [PATCH] NS1: TXT records are broken if they contain spaces (#270) * Integration tests: Add simple TXT tests. * NS1: Fix bug in TXT record handling. --- integrationTest/integration_test.go | 14 ++++++++++++++ providers/ns1/ns1provider.go | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 04e16d67f..47ea2e427 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -236,6 +236,10 @@ func srv(name string, priority, weight, port uint16, target string) *rec { return r } +func txt(name, target string) *rec { + return makeRec(name, target, "TXT") +} + func caa(name string, tag string, flag uint8, target string) *rec { r := makeRec(name, target, "CAA") r.CaaFlag = flag @@ -423,5 +427,15 @@ func makeTests(t *testing.T) []*TestCase { ) } + // Case + tests = append(tests, tc("Empty"), + // TXT + tc("Empty"), + tc("Create a TXT", txt("foo", "simple")), + tc("Change a TXT", txt("foo", "changed")), + tc("Create a TXT with spaces", txt("foo", "with spaces")), + tc("Change a TXT with spaces", txt("foo", "with whitespace")), + ) + return tests } diff --git a/providers/ns1/ns1provider.go b/providers/ns1/ns1provider.go index 787df1564..346179913 100644 --- a/providers/ns1/ns1provider.go +++ b/providers/ns1/ns1provider.go @@ -126,10 +126,11 @@ func buildRecord(recs models.Records, domain string, id string) *dns.Record { Zone: domain, } for _, r := range recs { - ans := &dns.Answer{ - Rdata: strings.Split(r.Target, " "), + if r.Type == "TXT" { + rec.AddAnswer(&dns.Answer{Rdata: []string{r.Target}}) + } else { + rec.AddAnswer(&dns.Answer{Rdata: strings.Split(r.Target, " ")}) } - rec.AddAnswer(ans) } return rec }