Skip to content

Commit

Permalink
Test for unsetting security policy
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst authored and modular-magician committed Jul 3, 2019
1 parent f0739d2 commit 53cba10
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,27 @@ func TestAccComputeBackendService_withSecurityPolicy(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeBackendService_withSecurityPolicy(serviceName, checkName, polName),
{
Config: testAccComputeBackendService_withSecurityPolicy(serviceName, checkName, polName, "${google_compute_security_policy.policy.self_link}"),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeBackendServiceExists(
"google_compute_backend_service.foobar", &svc),
resource.TestMatchResourceAttr("google_compute_backend_service.foobar", "security_policy", regexp.MustCompile(polName)),
),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendService_withSecurityPolicy(serviceName, checkName, polName, ""),
},
{
ResourceName: "google_compute_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -1017,12 +1030,12 @@ resource "google_compute_http_health_check" "zero" {
`, serviceName, checkName)
}

func testAccComputeBackendService_withSecurityPolicy(serviceName, checkName, polName string) string {
func testAccComputeBackendService_withSecurityPolicy(serviceName, checkName, polName, polLink string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
security_policy = "${google_compute_security_policy.policy.self_link}"
security_policy = "%s"
}

resource "google_compute_http_health_check" "zero" {
Expand All @@ -1036,7 +1049,7 @@ resource "google_compute_security_policy" "policy" {
name = "%s"
description = "basic security policy"
}
`, serviceName, checkName, polName)
`, serviceName, polLink, checkName, polName)
}

func testAccComputeBackendService_withMaxConnections(
Expand Down

0 comments on commit 53cba10

Please sign in to comment.