Skip to content

Commit 90ca3ee

Browse files
committed
Merge remote-tracking branch 'origin/mc-parameterized' into mc-parameterized
2 parents c4e2b4e + 205254c commit 90ca3ee

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

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

+78-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,31 @@ func testAccCheckOrgPolicyPolicyDestroyProducer(t *testing.T) func(s *terraform.
458458
return nil
459459
}
460460
}
461-
461+
func TestAccOrgPolicyPolicy_EnforceParameterizedMCPolicy(t *testing.T) {
462+
t.Parallel()
463+
464+
context := map[string]interface{}{
465+
"org_id": envvar.GetTestOrgFromEnv(t),
466+
"random_suffix": acctest.RandString(t, 10),
467+
}
468+
469+
acctest.VcrTest(t, resource.TestCase{
470+
PreCheck: func() { acctest.AccTestPreCheck(t) },
471+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
472+
CheckDestroy: testAccCheckOrgPolicyPolicyDestroyProducer(t),
473+
Steps: []resource.TestStep{
474+
{
475+
Config: testAccOrgPolicyPolicy_EnforceParameterizedMCPolicy(context),
476+
},
477+
{
478+
ResourceName: "google_org_policy_policy.primary",
479+
ImportState: true,
480+
ImportStateVerify: true,
481+
ImportStateVerifyIgnore: []string{"name", "spec.0.rules.0.condition.0.expression"},
482+
},
483+
},
484+
})
485+
}
462486
func testAccOrgPolicyPolicy_EnforceParameterizedMCPolicy(context map[string]interface{}) string {
463487
return acctest.Nprintf(`
464488
resource "google_org_policy_policy" "primary" {
@@ -484,5 +508,58 @@ resource "google_project" "basic" {
484508
}
485509
486510
511+
`, context)
512+
}
513+
514+
func TestAccOrgPolicyPolicy_EnforceParameterizedMCDryRunPolicy(t *testing.T) {
515+
t.Parallel()
516+
517+
context := map[string]interface{}{
518+
"org_id": envvar.GetTestOrgFromEnv(t),
519+
"random_suffix": acctest.RandString(t, 10),
520+
}
521+
522+
acctest.VcrTest(t, resource.TestCase{
523+
PreCheck: func() { acctest.AccTestPreCheck(t) },
524+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
525+
CheckDestroy: testAccCheckOrgPolicyPolicyDestroyProducer(t),
526+
Steps: []resource.TestStep{
527+
{
528+
Config: testAccOrgPolicyPolicy_EnforceParameterizedMCDryRunPolicy(context),
529+
},
530+
{
531+
ResourceName: "google_org_policy_policy.primary",
532+
ImportState: true,
533+
ImportStateVerify: true,
534+
ImportStateVerifyIgnore: []string{"name", "spec.0.rules.0.condition.0.expression"},
535+
},
536+
},
537+
})
538+
}
539+
func testAccOrgPolicyPolicy_EnforceParameterizedMCDryRunPolicy(context map[string]interface{}) string {
540+
return acctest.Nprintf(`
541+
resource "google_org_policy_policy" "primary" {
542+
name = "projects/${google_project.basic.name}/policies/constraints/compute.managed.restrictDiskCreation"
543+
parent = "projects/${google_project.basic.name}"
544+
545+
dry_run_spec {
546+
rules {
547+
enforce = "TRUE"
548+
parameters {
549+
"isSizeLimitCheck" = True,
550+
"allowedDiskTypes" = ["pd-ssd"]
551+
}
552+
}
553+
}
554+
}
555+
556+
resource "google_project" "basic" {
557+
project_id = "tf-test-id%{random_suffix}"
558+
name = "tf-test-id%{random_suffix}"
559+
org_id = "%{org_id}"
560+
deletion_policy = "DELETE"
561+
}
562+
563+
487564
`, context)
488565
}

0 commit comments

Comments
 (0)