From 5c32c76c24214fc7d0949f245c93c03a683da354 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 19 Apr 2023 17:35:31 +0000 Subject: [PATCH] Fix test for Ingress Policy (#7762) Signed-off-by: Modular Magician --- .changelog/7762.txt | 3 +++ ...e_access_context_manager_ingress_policy.go | 4 ++-- ...ess_context_manager_ingress_policy_test.go | 20 +++++-------------- ...ntext_manager_ingress_policy.html.markdown | 3 +-- 4 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 .changelog/7762.txt diff --git a/.changelog/7762.txt b/.changelog/7762.txt new file mode 100644 index 00000000000..87c61244aad --- /dev/null +++ b/.changelog/7762.txt @@ -0,0 +1,3 @@ +```release-note:bug +accesscontextmanager: fixed test for `google_access_context_manager_ingress_policy` +``` diff --git a/google/resource_access_context_manager_ingress_policy.go b/google/resource_access_context_manager_ingress_policy.go index 22b08b373a8..9f5bb665e9b 100644 --- a/google/resource_access_context_manager_ingress_policy.go +++ b/google/resource_access_context_manager_ingress_policy.go @@ -100,7 +100,7 @@ func resourceAccessContextManagerIngressPolicyCreate(d *schema.ResourceData, met } // Store the ID now - id, err := ReplaceVars(d, config, "{{ingress_policy_name}}{{resource}}") + id, err := ReplaceVars(d, config, "{{ingress_policy_name}}/{{resource}}") if err != nil { return fmt.Errorf("Error constructing id: %s", err) } @@ -134,7 +134,7 @@ func resourceAccessContextManagerIngressPolicyCreate(d *schema.ResourceData, met } // This may have caused the ID to update - update it if so. - id, err = ReplaceVars(d, config, "{{ingress_policy_name}}{{resource}}") + id, err = ReplaceVars(d, config, "{{ingress_policy_name}}/{{resource}}") if err != nil { return fmt.Errorf("Error constructing id: %s", err) } diff --git a/google/resource_access_context_manager_ingress_policy_test.go b/google/resource_access_context_manager_ingress_policy_test.go index b888069f936..4bb40f8413a 100644 --- a/google/resource_access_context_manager_ingress_policy_test.go +++ b/google/resource_access_context_manager_ingress_policy_test.go @@ -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), @@ -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 @@ -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 { diff --git a/website/docs/r/access_context_manager_ingress_policy.html.markdown b/website/docs/r/access_context_manager_ingress_policy.html.markdown index 22acba72910..03aca5d2d7d 100644 --- a/website/docs/r/access_context_manager_ingress_policy.html.markdown +++ b/website/docs/r/access_context_manager_ingress_policy.html.markdown @@ -55,7 +55,7 @@ The following arguments are supported: In addition to the arguments listed above, the following computed attributes are exported: -* `id` - an identifier for the resource with format `{{ingress_policy_name}}{{resource}}` +* `id` - an identifier for the resource with format `{{ingress_policy_name}}/{{resource}}` ## Timeouts @@ -73,5 +73,4 @@ IngressPolicy can be imported using any of these accepted formats: ``` $ terraform import google_access_context_manager_ingress_policy.default {{ingress_policy_name}}/{{resource}} -$ terraform import google_access_context_manager_ingress_policy.default {{ingress_policy_name}}{{resource}} ```