Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test for Ingress Policy #14361

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/7762.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
accesscontextmanager: fixed test for `google_access_context_manager_ingress_policy`
```
4 changes: 2 additions & 2 deletions google/resource_access_context_manager_ingress_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
20 changes: 5 additions & 15 deletions google/resource_access_context_manager_ingress_policy_test.go
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
```