From 2fb4a10e0c63d79808ef2665990f5c47af100334 Mon Sep 17 00:00:00 2001 From: Pasha Palangpour Date: Fri, 31 Mar 2017 16:27:01 -0500 Subject: [PATCH 1/2] provider/ns1: No splitting answer on spf records. --- builtin/providers/ns1/resource_record.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/ns1/resource_record.go b/builtin/providers/ns1/resource_record.go index 88b1a96c9d25..add703c3a1c8 100644 --- a/builtin/providers/ns1/resource_record.go +++ b/builtin/providers/ns1/resource_record.go @@ -236,7 +236,7 @@ func resourceDataToRecord(r *dns.Record, d *schema.ResourceData) error { var a *dns.Answer v := answer["answer"].(string) switch d.Get("type") { - case "TXT": + case "TXT", "SPF": a = dns.NewTXTAnswer(v) default: a = dns.NewAnswer(strings.Split(v, " ")) From 1cc24d47f3474aa6889825440ecd3b228e7b17b3 Mon Sep 17 00:00:00 2001 From: Pasha Palangpour Date: Fri, 7 Apr 2017 15:55:30 -0400 Subject: [PATCH 2/2] provider/ns1: Adds acctest for SPF records. --- builtin/providers/ns1/resource_record_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/builtin/providers/ns1/resource_record_test.go b/builtin/providers/ns1/resource_record_test.go index e73a143cc48e..36095b5795c9 100644 --- a/builtin/providers/ns1/resource_record_test.go +++ b/builtin/providers/ns1/resource_record_test.go @@ -71,6 +71,27 @@ func TestAccRecord_updated(t *testing.T) { }) } +func TestAccRecord_SPF(t *testing.T) { + var record dns.Record + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckRecordDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccRecordSPF, + Check: resource.ComposeTestCheckFunc( + testAccCheckRecordExists("ns1_record.spf", &record), + testAccCheckRecordDomain(&record, "terraform-record-test.io"), + testAccCheckRecordTTL(&record, 86400), + testAccCheckRecordUseClientSubnet(&record, true), + testAccCheckRecordAnswerRdata(&record, "v=DKIM1; k=rsa; p=XXXXXXXX"), + ), + }, + }, + }) +} + func testAccCheckRecordExists(n string, record *dns.Record) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -297,3 +318,20 @@ resource "ns1_zone" "test" { zone = "terraform-record-test.io" } ` + +const testAccRecordSPF = ` +resource "ns1_record" "spf" { + zone = "${ns1_zone.test.zone}" + domain = "${ns1_zone.test.zone}" + type = "SPF" + ttl = 86400 + use_client_subnet = "true" + answers = { + answer = "v=DKIM1; k=rsa; p=XXXXXXXX" + } +} + +resource "ns1_zone" "test" { + zone = "terraform-record-test.io" +} +`