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