Skip to content

Commit

Permalink
Fix test for Ingress Policy (GoogleCloudPlatform#7762)
Browse files Browse the repository at this point in the history
  • Loading branch information
hao-nan-li committed Apr 19, 2023
1 parent 6e9cd21 commit 24aed24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions mmv1/products/accesscontextmanager/IngressPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
exclude_validator: true
# Skipping the sweeper due to the non-standard base_url and because this is fine-grained under ServicePerimeter/IngressPolicy
skip_sweeper: true
id_format: "{{ingress_policy_name}}{{resource}}"
import_format: ["{{ingress_policy_name}}{{resource}}"]
id_format: "{{ingress_policy_name}}/{{resource}}"
import_format: ["{{ingress_policy_name}}/{{resource}}"]
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/access_context_manager_service_perimeter_ingress_policy.go.erb
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,22 @@ func testAccAccessContextManagerIngressPolicy_basicTest(t *testing.T) {
// Multiple fine-grained resources
SkipIfVcr(t)
org := GetTestOrgFromEnv(t)
projects := BootstrapServicePerimeterProjects(t, 2)
projects := BootstrapServicePerimeterProjects(t, 1)
policyTitle := RandString(t, 10)
perimeterTitle := RandString(t, 10)
perimeterTitle := "perimeter"

VcrTest(t, resource.TestCase{
PreCheck: func() { AccTestPreCheck(t) },
ProtoV5ProviderFactories: ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitle, projects[0].ProjectNumber, projects[1].ProjectNumber),
Config: testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitle, projects[0].ProjectNumber),
},
{
ResourceName: "google_access_context_manager_ingress_policy.test-access1",
ImportState: true,
ImportStateVerify: true,
},
{
ResourceName: "google_access_context_manager_ingress_policy.test-access2",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitle),
Check: testAccCheckAccessContextManagerIngressPolicyDestroyProducer(t),
Expand Down Expand Up @@ -86,7 +81,7 @@ func testAccCheckAccessContextManagerIngressPolicyDestroyProducer(t *testing.T)
}
}

func testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitleName string, projectNumber1, projectNumber2 int64) string {
func testAccAccessContextManagerIngressPolicy_basic(org, policyTitle, perimeterTitleName string, projectNumber1 int64) string {
return fmt.Sprintf(`
%s
Expand All @@ -95,12 +90,7 @@ resource "google_access_context_manager_ingress_policy" "test-access1" {
resource = "projects/%d"
}
resource "google_access_context_manager_ingress_policy" "test-access2" {
ingress_policy_name = google_access_context_manager_service_perimeter.test-access.name
resource = "projects/%d"
}
`, testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitleName), projectNumber1, projectNumber2)
`, testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitleName), projectNumber1)
}

func testAccAccessContextManagerIngressPolicy_destroy(org, policyTitle, perimeterTitleName string) string {
Expand Down

0 comments on commit 24aed24

Please sign in to comment.