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