-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for google_access_context_manager_service_perimeter
- Loading branch information
1 parent
51920e5
commit 4ab1cc7
Showing
4 changed files
with
808 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
google-beta/resource_access_context_manager_service_perimeter_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/resource" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
// Access Context Manager tests need to run serially | ||
func TestAccAccessContextManagerServicePerimeter_basic(t *testing.T) { | ||
org := getTestOrgFromEnv(t) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAccessContextManagerServicePerimeterDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAccessContextManagerServicePerimeter_basic(org, "my policy", "level", "perimeter"), | ||
}, | ||
{ | ||
ResourceName: "google_access_context_manager_service_perimeter.test-access", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAccessContextManagerServicePerimeterDestroy(s *terraform.State) error { | ||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_access_context_manager_service_perimeter" { | ||
continue | ||
} | ||
|
||
config := testAccProvider.Meta().(*Config) | ||
|
||
url, err := replaceVarsForTest(rs, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = sendRequest(config, "GET", url, nil) | ||
if err == nil { | ||
return fmt.Errorf("ServicePerimeter still exists at %s", url) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func testAccAccessContextManagerServicePerimeter_basic(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" | ||
title = "%s" | ||
perimeter_type = "PERIMETER_TYPE_REGULAR" | ||
status { | ||
restricted_services = ["*"] | ||
} | ||
} | ||
`, org, policyTitle, levelTitleName, levelTitleName, perimeterTitleName, perimeterTitleName) | ||
} |
Oops, something went wrong.