Skip to content

Commit 2d0dcb7

Browse files
authored
Update test org for org policy test (#15770)
1 parent a21fd14 commit 2d0dcb7

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

mmv1/products/orgpolicy/CustomConstraint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ examples:
3939
vars:
4040
policy_name: 'custom.disableGkeAutoUpgrade'
4141
test_env_vars:
42-
org_id: 'ORG_ID'
42+
org_id: 'ORG_TARGET'
4343
test_vars_overrides:
4444
'policy_name': '"custom.tfTestDisableGkeAutoUpgrade" + acctest.RandString(t, 10)'
4545
- name: 'org_policy_custom_constraint_full'

mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_custom_constraint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestAccOrgPolicyCustomConstraint_update(t *testing.T) {
1212
t.Parallel()
1313

1414
context := map[string]interface{}{
15-
"org_id": envvar.GetTestOrgFromEnv(t),
15+
"org_id": envvar.GetTestOrgTargetFromEnv(t),
1616
"random_suffix": acctest.RandString(t, 10),
1717
}
1818

mmv1/third_party/terraform/services/orgpolicy/resource_org_policy_policy_test.go

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestAccOrgPolicyPolicy_OrganizationPolicy(t *testing.T) {
7777
t.Parallel()
7878

7979
context := map[string]interface{}{
80-
"org_id": envvar.GetTestOrgFromEnv(t),
80+
"org_id": envvar.GetTestOrgTargetFromEnv(t),
8181
"random_suffix": acctest.RandString(t, 10),
8282
}
8383

@@ -104,6 +104,15 @@ func TestAccOrgPolicyPolicy_OrganizationPolicy(t *testing.T) {
104104
ImportStateVerify: true,
105105
ImportStateVerifyIgnore: []string{"name", "spec.0.rules.0.condition.0.expression"},
106106
},
107+
{
108+
Config: testAccOrgPolicyPolicy_DryRunSpecHandWritten(context),
109+
},
110+
{
111+
ResourceName: "google_org_policy_policy.primary",
112+
ImportState: true,
113+
ImportStateVerify: true,
114+
ImportStateVerifyIgnore: []string{"name", "spec.0.rules.0.condition.0.expression"},
115+
},
107116
},
108117
})
109118
}
@@ -150,31 +159,6 @@ func TestAccOrgPolicyPolicy_ProjectPolicy(t *testing.T) {
150159
},
151160
})
152161
}
153-
func TestAccOrgPolicyPolicy_DryRunSpecHandWritten(t *testing.T) {
154-
t.Parallel()
155-
156-
context := map[string]interface{}{
157-
"org_id": envvar.GetTestOrgFromEnv(t),
158-
"random_suffix": acctest.RandString(t, 10),
159-
}
160-
161-
acctest.VcrTest(t, resource.TestCase{
162-
PreCheck: func() { acctest.AccTestPreCheck(t) },
163-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
164-
CheckDestroy: testAccCheckOrgPolicyPolicyDestroyProducer(t),
165-
Steps: []resource.TestStep{
166-
{
167-
Config: testAccOrgPolicyPolicy_DryRunSpecHandWritten(context),
168-
},
169-
{
170-
ResourceName: "google_org_policy_policy.primary",
171-
ImportState: true,
172-
ImportStateVerify: true,
173-
ImportStateVerifyIgnore: []string{"name", "spec.0.rules.0.condition.0.expression"},
174-
},
175-
},
176-
})
177-
}
178162

179163
func testAccOrgPolicyPolicy_EnforcePolicy(context map[string]interface{}) string {
180164
return acctest.Nprintf(`
@@ -266,7 +250,7 @@ resource "google_folder" "basic" {
266250
func testAccOrgPolicyPolicy_OrganizationPolicy(context map[string]interface{}) string {
267251
return acctest.Nprintf(`
268252
resource "google_org_policy_custom_constraint" "constraint" {
269-
name = "custom.tfTest%{random_suffix}"
253+
name = "custom.tfTestdisableGkeAutoUpgrade%{random_suffix}"
270254
parent = "organizations/%{org_id}"
271255
display_name = "Disable GKE auto upgrade"
272256
description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."
@@ -291,7 +275,7 @@ resource "google_org_policy_policy" "primary" {
291275
func testAccOrgPolicyPolicy_OrganizationPolicyUpdate0(context map[string]interface{}) string {
292276
return acctest.Nprintf(`
293277
resource "google_org_policy_custom_constraint" "constraint" {
294-
name = "custom.tfTest%{random_suffix}"
278+
name = "custom.tfTestdisableGkeAutoUpgrade%{random_suffix}"
295279
parent = "organizations/%{org_id}"
296280
display_name = "Disable GKE auto upgrade"
297281
description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."
@@ -429,14 +413,14 @@ resource "google_project" "basic" {
429413
func testAccOrgPolicyPolicy_DryRunSpecHandWritten(context map[string]interface{}) string {
430414
return acctest.Nprintf(`
431415
resource "google_org_policy_custom_constraint" "constraint" {
432-
name = "custom.disableGkeAutoUpgrade%{random_suffix}"
416+
name = "custom.tfTestdisableGkeAutoUpgrade%{random_suffix}"
433417
parent = "organizations/%{org_id}"
434418
display_name = "Disable GKE auto upgrade"
435419
description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."
436420
437421
action_type = "ALLOW"
438422
condition = "resource.management.autoUpgrade == false"
439-
method_types = ["CREATE"]
423+
method_types = ["CREATE", "UPDATE"]
440424
resource_types = ["container.googleapis.com/NodePool"]
441425
}
442426

0 commit comments

Comments
 (0)