@@ -50,6 +50,50 @@ func TestAccNetworkSecurityGatewaySecurityPolicyRule_update(t *testing.T) {
50
50
})
51
51
}
52
52
53
+ func TestAccNetworkSecurityGatewaySecurityPolicyRule_multiple (t * testing.T ) {
54
+ t .Parallel ()
55
+
56
+ context := map [string ]interface {}{
57
+ "random_suffix" : acctest .RandString (t , 10 ),
58
+ }
59
+
60
+ acctest .VcrTest (t , resource.TestCase {
61
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
62
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
63
+ CheckDestroy : testAccCheckNetworkSecurityGatewaySecurityPolicyRuleDestroyProducer (t ),
64
+ Steps : []resource.TestStep {
65
+ {
66
+ Config : testAccNetworkSecurityGatewaySecurityPolicyRule_multiple (context ),
67
+ },
68
+ {
69
+ ResourceName : "google_network_security_gateway_security_policy_rule.rule1" ,
70
+ ImportState : true ,
71
+ ImportStateVerify : true ,
72
+ },
73
+ {
74
+ ResourceName : "google_network_security_gateway_security_policy_rule.rule2" ,
75
+ ImportState : true ,
76
+ ImportStateVerify : true ,
77
+ },
78
+ {
79
+ ResourceName : "google_network_security_gateway_security_policy_rule.rule3" ,
80
+ ImportState : true ,
81
+ ImportStateVerify : true ,
82
+ },
83
+ {
84
+ ResourceName : "google_network_security_gateway_security_policy_rule.rule4" ,
85
+ ImportState : true ,
86
+ ImportStateVerify : true ,
87
+ },
88
+ {
89
+ ResourceName : "google_network_security_gateway_security_policy_rule.rule5" ,
90
+ ImportState : true ,
91
+ ImportStateVerify : true ,
92
+ },
93
+ },
94
+ })
95
+ }
96
+
53
97
func testAccNetworkSecurityGatewaySecurityPolicyRule_basic (gatewaySecurityPolicyName , gatewaySecurityPolicyRuleName string ) string {
54
98
return fmt .Sprintf (`
55
99
resource "google_network_security_gateway_security_policy" "default" {
@@ -94,3 +138,76 @@ resource "google_network_security_gateway_security_policy_rule" "foobar" {
94
138
}
95
139
` , gatewaySecurityPolicyName , gatewaySecurityPolicyRuleName )
96
140
}
141
+
142
+ func testAccNetworkSecurityGatewaySecurityPolicyRule_multiple (context map [string ]interface {}) string {
143
+ return acctest .Nprintf (`
144
+ resource "google_network_security_gateway_security_policy" "default" {
145
+ name = "tf-test-gateway-sp-%{random_suffix}"
146
+ location = "us-central1"
147
+ description = "gateway security policy created to be used as reference by the rule."
148
+ }
149
+
150
+ resource "google_network_security_gateway_security_policy_rule" "rule1" {
151
+ name = "tf-test-gateway-sp-rule1-%{random_suffix}"
152
+ location = "us-central1"
153
+ gateway_security_policy = google_network_security_gateway_security_policy.default.name
154
+ enabled = true
155
+ description = "Highest priority rule"
156
+ priority = 0
157
+ session_matcher = "host() == 'example.com'"
158
+ application_matcher = "request.method == 'POST'"
159
+ basic_profile = "ALLOW"
160
+ }
161
+
162
+ resource "google_network_security_gateway_security_policy_rule" "rule2" {
163
+ name = "tf-test-gateway-sp-rule2-%{random_suffix}"
164
+ location = "us-central1"
165
+ gateway_security_policy = google_network_security_gateway_security_policy.default.name
166
+ enabled = true
167
+ description = "Rule priority 762"
168
+ priority = 762
169
+ session_matcher = "host() == 'example.com'"
170
+ application_matcher = "request.method == 'GET'"
171
+ tls_inspection_enabled = false
172
+ basic_profile = "DENY"
173
+ }
174
+
175
+ resource "google_network_security_gateway_security_policy_rule" "rule3" {
176
+ name = "tf-test-gateway-sp-rule3-%{random_suffix}"
177
+ location = "us-central1"
178
+ gateway_security_policy = google_network_security_gateway_security_policy.default.name
179
+ enabled = true
180
+ description = "Rule priority 37961"
181
+ priority = 37961
182
+ session_matcher = "host() == 'update.com'"
183
+ application_matcher = "request.method == 'POST'"
184
+ basic_profile = "ALLOW"
185
+ }
186
+
187
+ resource "google_network_security_gateway_security_policy_rule" "rule4" {
188
+ name = "tf-test-gateway-sp-rule4-%{random_suffix}"
189
+ location = "us-central1"
190
+ gateway_security_policy = google_network_security_gateway_security_policy.default.name
191
+ enabled = true
192
+ description = "Rule priority 9572843"
193
+ priority = 9572843
194
+ session_matcher = "host() == 'update.com'"
195
+ application_matcher = "request.method == 'GET'"
196
+ tls_inspection_enabled = false
197
+ basic_profile = "DENY"
198
+ }
199
+
200
+ resource "google_network_security_gateway_security_policy_rule" "rule5" {
201
+ name = "tf-test-gateway-sp-rule5-%{random_suffix}"
202
+ location = "us-central1"
203
+ gateway_security_policy = google_network_security_gateway_security_policy.default.name
204
+ enabled = true
205
+ description = "Lowest priority rule"
206
+ priority = 2147483647
207
+ session_matcher = "host() == 'update.com'"
208
+ application_matcher = "request.method == 'GET'"
209
+ tls_inspection_enabled = false
210
+ basic_profile = "DENY"
211
+ }
212
+ ` , context )
213
+ }
0 commit comments