Skip to content

Commit

Permalink
fix dnssec test (hashicorp#777)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and danawillow committed May 29, 2019
1 parent 88ce1ea commit 2f94236
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 10 deletions.
2 changes: 2 additions & 0 deletions google-beta/resource_dns_managed_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func resourceDnsManagedZone() *schema.Resource {
Schema: map[string]*schema.Schema{
"default_key_specs": {
Type: schema.TypeList,
Computed: true,
Optional: true,
ForceNew: true,
Elem: &schema.Resource{
Expand Down Expand Up @@ -107,6 +108,7 @@ func resourceDnsManagedZone() *schema.Resource {
},
"non_existence": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"nsec", "nsec3", ""}, false),
Expand Down
87 changes: 79 additions & 8 deletions google-beta/resource_dns_managed_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,51 @@ func TestAccDnsManagedZone_privateUpdate(t *testing.T) {
},
})
}

func TestAccDnsManagedZone_dnssec_on(t *testing.T) {
t.Parallel()

zoneSuffix := acctest.RandString(10)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDnsManagedZoneDestroy,
Steps: []resource.TestStep{
{
Config: testAccDnsManagedZone_dnssec_on(zoneSuffix),
},
{
ResourceName: "google_dns_managed_zone.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccDnsManagedZone_dnssec_off(t *testing.T) {
t.Parallel()

zoneSuffix := acctest.RandString(10)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDnsManagedZoneDestroy,
Steps: []resource.TestStep{
{
Config: testAccDnsManagedZone_dnssec_off(zoneSuffix),
},
{
ResourceName: "google_dns_managed_zone.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccDnsManagedZone_privateForwardingUpdate(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -111,6 +156,40 @@ resource "google_dns_managed_zone" "foobar" {
}`, suffix, suffix, description)
}

func testAccDnsManagedZone_dnssec_on(suffix string) string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "foobar" {
name = "mzone-test-%s"
dns_name = "tf-acctest-%s.hashicorptest.com."
dnssec_config {
state = "on"
default_key_specs {
algorithm = "rsasha256"
key_length = "2048"
key_type = "zoneSigning"
}
default_key_specs {
algorithm = "rsasha256"
key_length = "2048"
key_type = "keySigning"
}
}
}`, suffix, suffix)
}

func testAccDnsManagedZone_dnssec_off(suffix string) string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "foobar" {
name = "mzone-test-%s"
dns_name = "tf-acctest-%s.hashicorptest.com."
dnssec_config {
state = "off"
}
}`, suffix, suffix)
}

func testAccDnsManagedZone_privateUpdate(suffix, first_network, second_network string) string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "private" {
Expand All @@ -125,14 +204,6 @@ resource "google_dns_managed_zone" "private" {
networks {
network_url = "${google_compute_network.%s.self_link}"
}
dnssec_config {
state = "on"
default_key_specs {
algorithm = "rsasha1"
key_length = "128"
key_type = "zoneSigning"
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/dns_managed_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ The `dnssec_config` block supports:

* `non_existence` -
(Optional)
Specifies the mechanism used to provide authenticated denial-of-existence responses. Output only while state is not OFF.
Specifies the mechanism used to provide authenticated denial-of-existence responses.

* `state` -
(Optional)
Expand All @@ -263,7 +263,8 @@ The `dnssec_config` block supports:
* `default_key_specs` -
(Optional)
Specifies parameters that will be used for generating initial DnsKeys
for this ManagedZone. Output only while state is not OFF Structure is documented below.
for this ManagedZone. If you provide a spec for keySigning or zoneSigning,
you must also provide one for the other. Structure is documented below.


The `default_key_specs` block supports:
Expand Down

0 comments on commit 2f94236

Please sign in to comment.