|
| 1 | +package securitycenter_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 7 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 8 | + "github.com/hashicorp/terraform-provider-google/google/envvar" |
| 9 | +) |
| 10 | + |
| 11 | +func TestAccSecurityCenterMuteConfig(t *testing.T) { |
| 12 | + t.Parallel() |
| 13 | + |
| 14 | + context := map[string]interface{}{ |
| 15 | + "org_id": envvar.GetTestOrgFromEnv(t), |
| 16 | + "random_suffix": acctest.RandString(t, 10), |
| 17 | + } |
| 18 | + |
| 19 | + acctest.VcrTest(t, resource.TestCase{ |
| 20 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 21 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 22 | + ExternalProviders: map[string]resource.ExternalProvider{ |
| 23 | + "random": {}, |
| 24 | + "time": {}, |
| 25 | + }, |
| 26 | + Steps: []resource.TestStep{ |
| 27 | + { |
| 28 | + Config: testAccSecurityCenterMuteConfig_basic(context), |
| 29 | + }, |
| 30 | + { |
| 31 | + ResourceName: "google_scc_mute_config.default", |
| 32 | + ImportState: true, |
| 33 | + ImportStateVerify: true, |
| 34 | + ImportStateVerifyIgnore: []string{ |
| 35 | + "mute_config_id", |
| 36 | + }, |
| 37 | + }, |
| 38 | + { |
| 39 | + Config: testAccSecurityCenterMuteConfig_update(context), |
| 40 | + }, |
| 41 | + { |
| 42 | + ResourceName: "google_scc_mute_config.default", |
| 43 | + ImportState: true, |
| 44 | + ImportStateVerify: true, |
| 45 | + ImportStateVerifyIgnore: []string{ |
| 46 | + "mute_config_id", |
| 47 | + }, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }) |
| 51 | +} |
| 52 | + |
| 53 | +func testAccSecurityCenterMuteConfig_basic(context map[string]interface{}) string { |
| 54 | + return acctest.Nprintf(` |
| 55 | +
|
| 56 | +resource "google_scc_mute_config" "default" { |
| 57 | + mute_config_id = "tf-test-mute-config-%{random_suffix}" |
| 58 | + parent = "organizations/%{org_id}" |
| 59 | + filter = "category: \"OS_VULNERABILITY\"" |
| 60 | + description = "A Test Mute Config" |
| 61 | + type = "DYNAMIC" |
| 62 | + expiry_time = "2215-02-03T15:01:23Z" |
| 63 | +} |
| 64 | +`, context) |
| 65 | +} |
| 66 | + |
| 67 | +func testAccSecurityCenterMuteConfig_update(context map[string]interface{}) string { |
| 68 | + return acctest.Nprintf(` |
| 69 | +
|
| 70 | +resource "google_scc_mute_config" "default" { |
| 71 | + mute_config_id = "tf-test-mute-config-%{random_suffix}" |
| 72 | + parent = "organizations/%{org_id}" |
| 73 | + filter = "category: \"OS_VULNERABILITY\"" |
| 74 | + description = "An Updated Test Mute Config" |
| 75 | + type = "DYNAMIC" |
| 76 | + expiry_time = "2215-02-03T15:01:23Z" |
| 77 | +} |
| 78 | +`, context) |
| 79 | +} |
0 commit comments