|
4 | 4 | "fmt"
|
5 | 5 | "testing"
|
6 | 6 |
|
| 7 | + "github.com/hashicorp/terraform-plugin-testing/plancheck" |
7 | 8 | "github.com/hashicorp/terraform-plugin-testing/helper/resource"
|
8 | 9 | "github.com/hashicorp/terraform-provider-google/google/acctest"
|
9 | 10 | "github.com/hashicorp/terraform-provider-google/google/envvar"
|
@@ -42,6 +43,58 @@ func TestAccNetworkSecuritySecurityProfiles_update(t *testing.T) {
|
42 | 43 | })
|
43 | 44 | }
|
44 | 45 |
|
| 46 | +func TestAccNetworkSecuritySecurityProfiles_antivirusOverrides(t *testing.T) { |
| 47 | + t.Parallel() |
| 48 | + |
| 49 | + orgId := envvar.GetTestOrgFromEnv(t) |
| 50 | + randomSuffix := acctest.RandString(t, 10) |
| 51 | + |
| 52 | + acctest.VcrTest(t, resource.TestCase{ |
| 53 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 54 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 55 | + CheckDestroy: testAccCheckNetworkSecuritySecurityProfileDestroyProducer(t), |
| 56 | + Steps: []resource.TestStep{ |
| 57 | + { |
| 58 | + Config: testAccNetworkSecuritySecurityProfiles_basic(orgId, randomSuffix), |
| 59 | + }, |
| 60 | + { |
| 61 | + ResourceName: "google_network_security_security_profile.foobar", |
| 62 | + ImportState: true, |
| 63 | + ImportStateVerify: true, |
| 64 | + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, |
| 65 | + }, |
| 66 | + { |
| 67 | + Config: testAccNetworkSecuritySecurityProfiles_antivirusOverrides(orgId, randomSuffix), |
| 68 | + ConfigPlanChecks: resource.ConfigPlanChecks{ |
| 69 | + PreApply: []plancheck.PlanCheck{ |
| 70 | + plancheck.ExpectResourceAction("google_network_security_security_profile.foobar", plancheck.ResourceActionUpdate), |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + { |
| 75 | + ResourceName: "google_network_security_security_profile.foobar", |
| 76 | + ImportState: true, |
| 77 | + ImportStateVerify: true, |
| 78 | + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, |
| 79 | + }, |
| 80 | + { |
| 81 | + Config: testAccNetworkSecuritySecurityProfiles_basic(orgId, randomSuffix), |
| 82 | + ConfigPlanChecks: resource.ConfigPlanChecks{ |
| 83 | + PreApply: []plancheck.PlanCheck{ |
| 84 | + plancheck.ExpectResourceAction("google_network_security_security_profile.foobar", plancheck.ResourceActionUpdate), |
| 85 | + }, |
| 86 | + }, |
| 87 | + }, |
| 88 | + { |
| 89 | + ResourceName: "google_network_security_security_profile.foobar", |
| 90 | + ImportState: true, |
| 91 | + ImportStateVerify: true, |
| 92 | + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, |
| 93 | + }, |
| 94 | + }, |
| 95 | + }) |
| 96 | +} |
| 97 | + |
45 | 98 | func testAccNetworkSecuritySecurityProfiles_basic(orgId string, randomSuffix string) string {
|
46 | 99 | return fmt.Sprintf(`
|
47 | 100 | resource "google_network_security_security_profile" "foobar" {
|
@@ -85,3 +138,36 @@ resource "google_network_security_security_profile" "foobar" {
|
85 | 138 | }
|
86 | 139 | `, randomSuffix, orgId)
|
87 | 140 | }
|
| 141 | + |
| 142 | +func testAccNetworkSecuritySecurityProfiles_antivirusOverrides(orgId string, randomSuffix string) string { |
| 143 | + return fmt.Sprintf(` |
| 144 | +resource "google_network_security_security_profile" "foobar" { |
| 145 | + name = "tf-test-my-security-profile%s" |
| 146 | + parent = "organizations/%s" |
| 147 | + location = "global" |
| 148 | + description = "My security profile. Update" |
| 149 | + type = "THREAT_PREVENTION" |
| 150 | + |
| 151 | + labels = { |
| 152 | + foo = "foo" |
| 153 | + } |
| 154 | + |
| 155 | + threat_prevention_profile { |
| 156 | + antivirus_overrides { |
| 157 | + action = "ALLOW" |
| 158 | + protocol = "FTP" |
| 159 | + } |
| 160 | + |
| 161 | + antivirus_overrides { |
| 162 | + action = "DENY" |
| 163 | + protocol = "HTTP" |
| 164 | + } |
| 165 | + |
| 166 | + antivirus_overrides { |
| 167 | + action = "ALERT" |
| 168 | + protocol = "HTTP2" |
| 169 | + } |
| 170 | + } |
| 171 | +} |
| 172 | +`, randomSuffix, orgId) |
| 173 | +} |
0 commit comments