Skip to content

Commit

Permalink
fix service perimeter tests (hashicorp#890)
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 Jun 26, 2019
1 parent bb49ae9 commit 54711b2
Showing 1 changed file with 7 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func testAccAccessContextManagerServicePerimeter_updateTest(t *testing.T) {
CheckDestroy: testAccCheckAccessContextManagerServicePerimeterDestroy,
Steps: []resource.TestStep{
{
Config: testAccAccessContextManagerServicePerimeter_update(org, "my policy", "level", "perimeter"),
Config: testAccAccessContextManagerServicePerimeter_basic(org, "my policy", "level", "perimeter"),
},
{
ResourceName: "google_access_context_manager_service_perimeter.test-access",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAccessContextManagerServicePerimeter_update2(org, "my policy", "level", "perimeter"),
Config: testAccAccessContextManagerServicePerimeter_update(org, "my policy", "level", "perimeter"),
},
{
ResourceName: "google_access_context_manager_service_perimeter.test-access",
Expand Down Expand Up @@ -100,35 +100,6 @@ resource "google_access_context_manager_access_level" "test-access" {
}
}
resource "google_access_context_manager_service_perimeter" "test-access" {
parent = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}"
name = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}/servicePerimeters/%s"
title = "%s"
perimeter_type = "PERIMETER_TYPE_BRIDGE"
}
`, org, policyTitle, levelTitleName, levelTitleName, perimeterTitleName, perimeterTitleName)
}

func testAccAccessContextManagerServicePerimeter_update(org, policyTitle, levelTitleName, perimeterTitleName string) string {
return fmt.Sprintf(`
resource "google_access_context_manager_access_policy" "test-access" {
parent = "organizations/%s"
title = "%s"
}
resource "google_access_context_manager_access_level" "test-access" {
parent = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}"
name = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}/accessLevels/%s"
title = "%s"
description = "hello"
basic {
combining_function = "AND"
conditions {
ip_subnetworks = ["192.0.4.0/24"]
}
}
}
resource "google_access_context_manager_service_perimeter" "test-access" {
parent = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}"
name = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}/servicePerimeters/%s"
Expand All @@ -141,7 +112,7 @@ resource "google_access_context_manager_service_perimeter" "test-access" {
`, org, policyTitle, levelTitleName, levelTitleName, perimeterTitleName, perimeterTitleName)
}

func testAccAccessContextManagerServicePerimeter_update2(org, policyTitle, levelTitleName, perimeterTitleName string) string {
func testAccAccessContextManagerServicePerimeter_update(org, policyTitle, levelTitleName, perimeterTitleName string) string {
return fmt.Sprintf(`
resource "google_access_context_manager_access_policy" "test-access" {
parent = "organizations/%s"
Expand All @@ -166,6 +137,10 @@ resource "google_access_context_manager_service_perimeter" "test-access" {
name = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}/servicePerimeters/%s"
title = "%s"
perimeter_type = "PERIMETER_TYPE_REGULAR"
status {
restricted_services = ["bigquery.googleapis.com"]
access_levels = ["${google_access_context_manager_access_level.test-access.name}"]
}
}
`, org, policyTitle, levelTitleName, levelTitleName, perimeterTitleName, perimeterTitleName)
}

0 comments on commit 54711b2

Please sign in to comment.