@@ -14,7 +14,7 @@ import (
14
14
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
15
15
)
16
16
17
- func TestAccTencentCloudSecurityGroupRule_basic (t * testing.T ) {
17
+ func TestAccTencentCloudSecurityGroupRuleResource_basic (t * testing.T ) {
18
18
t .Parallel ()
19
19
var sgrId string
20
20
@@ -39,7 +39,46 @@ func TestAccTencentCloudSecurityGroupRule_basic(t *testing.T) {
39
39
})
40
40
}
41
41
42
- func TestAccTencentCloudSecurityGroupRule_ssh (t * testing.T ) {
42
+ func TestAccTencentCloudSecurityGroupRuleResource_multi (t * testing.T ) {
43
+ t .Parallel ()
44
+ var sgrId string
45
+
46
+ resource .Test (t , resource.TestCase {
47
+ PreCheck : func () { tcacctest .AccPreCheck (t ) },
48
+ Providers : tcacctest .AccProviders ,
49
+ CheckDestroy : testAccCheckSecurityGroupRuleDestroy (& sgrId ),
50
+ Steps : []resource.TestStep {
51
+ {
52
+ Config : testAccSecurityGroupRuleConfigMulti ,
53
+ Check : resource .ComposeTestCheckFunc (
54
+ testAccCheckSecurityGroupRuleExists ("tencentcloud_security_group_rule.http-in1" , & sgrId ),
55
+ testAccCheckSecurityGroupRuleExists ("tencentcloud_security_group_rule.http-in2" , & sgrId ),
56
+ testAccCheckSecurityGroupRuleExists ("tencentcloud_security_group_rule.http-in3" , & sgrId ),
57
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in1" , "cidr_ip" , "1.1.1.1" ),
58
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in1" , "ip_protocol" , "tcp" ),
59
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in1" , "description" , "" ),
60
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in1" , "type" , "ingress" ),
61
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in1" , "policy_index" , "0" ),
62
+ resource .TestCheckNoResourceAttr ("tencentcloud_security_group_rule.http-in1" , "source_sgid" ),
63
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in2" , "cidr_ip" , "2.2.2.2" ),
64
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in2" , "ip_protocol" , "tcp" ),
65
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in2" , "description" , "" ),
66
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in2" , "type" , "ingress" ),
67
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in2" , "policy_index" , "0" ),
68
+ resource .TestCheckNoResourceAttr ("tencentcloud_security_group_rule.http-in2" , "source_sgid" ),
69
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in3" , "cidr_ip" , "3.3.3.3" ),
70
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in3" , "ip_protocol" , "tcp" ),
71
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in3" , "description" , "" ),
72
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in3" , "type" , "ingress" ),
73
+ resource .TestCheckResourceAttr ("tencentcloud_security_group_rule.http-in3" , "policy_index" , "0" ),
74
+ resource .TestCheckNoResourceAttr ("tencentcloud_security_group_rule.http-in3" , "source_sgid" ),
75
+ ),
76
+ },
77
+ },
78
+ })
79
+ }
80
+
81
+ func TestAccTencentCloudSecurityGroupRuleResource_ssh (t * testing.T ) {
43
82
t .Parallel ()
44
83
var sgrId string
45
84
@@ -63,7 +102,7 @@ func TestAccTencentCloudSecurityGroupRule_ssh(t *testing.T) {
63
102
})
64
103
}
65
104
66
- func TestAccTencentCloudSecurityGroupRule_egress (t * testing.T ) {
105
+ func TestAccTencentCloudSecurityGroupRuleResource_egress (t * testing.T ) {
67
106
t .Parallel ()
68
107
var sgrId string
69
108
@@ -88,7 +127,7 @@ func TestAccTencentCloudSecurityGroupRule_egress(t *testing.T) {
88
127
})
89
128
}
90
129
91
- func TestAccTencentCloudSecurityGroupRule_sourcesgid (t * testing.T ) {
130
+ func TestAccTencentCloudSecurityGroupRuleResource_sourcesgid (t * testing.T ) {
92
131
t .Parallel ()
93
132
var sgrId string
94
133
@@ -112,7 +151,7 @@ func TestAccTencentCloudSecurityGroupRule_sourcesgid(t *testing.T) {
112
151
})
113
152
}
114
153
115
- func TestAccTencentCloudSecurityGroupRule_allDrop (t * testing.T ) {
154
+ func TestAccTencentCloudSecurityGroupRuleResource_allDrop (t * testing.T ) {
116
155
t .Parallel ()
117
156
var sgrId string
118
157
@@ -136,7 +175,7 @@ func TestAccTencentCloudSecurityGroupRule_allDrop(t *testing.T) {
136
175
})
137
176
}
138
177
139
- func TestAccTencentCloudSecurityGroupRule_addressTemplate (t * testing.T ) {
178
+ func TestAccTencentCloudSecurityGroupRuleResource_addressTemplate (t * testing.T ) {
140
179
t .Parallel ()
141
180
var sgrId string
142
181
resource .Test (t , resource.TestCase {
@@ -167,7 +206,7 @@ func TestAccTencentCloudSecurityGroupRule_addressTemplate(t *testing.T) {
167
206
})
168
207
}
169
208
170
- func TestAccTencentCloudSecurityGroupRule_protocolTemplate (t * testing.T ) {
209
+ func TestAccTencentCloudSecurityGroupRuleResource_protocolTemplate (t * testing.T ) {
171
210
t .Parallel ()
172
211
var sgrId string
173
212
resource .Test (t , resource.TestCase {
@@ -264,6 +303,43 @@ resource "tencentcloud_security_group_rule" "http-in" {
264
303
}
265
304
`
266
305
306
+ const testAccSecurityGroupRuleConfigMulti = `
307
+ resource "tencentcloud_security_group" "foo" {
308
+ name = "ci-temp-test-sg"
309
+ description = "ci-temp-test-sg"
310
+ }
311
+
312
+ resource "tencentcloud_security_group_rule" "http-in1" {
313
+ security_group_id = tencentcloud_security_group.foo.id
314
+ type = "ingress"
315
+ cidr_ip = "1.1.1.1"
316
+ ip_protocol = "tcp"
317
+ port_range = "80,8080"
318
+ policy = "accept"
319
+ policy_index = 0
320
+ }
321
+
322
+ resource "tencentcloud_security_group_rule" "http-in2" {
323
+ security_group_id = tencentcloud_security_group.foo.id
324
+ type = "ingress"
325
+ cidr_ip = "2.2.2.2"
326
+ ip_protocol = "tcp"
327
+ port_range = "80,8080"
328
+ policy = "accept"
329
+ policy_index = 0
330
+ }
331
+
332
+ resource "tencentcloud_security_group_rule" "http-in3" {
333
+ security_group_id = tencentcloud_security_group.foo.id
334
+ type = "ingress"
335
+ cidr_ip = "3.3.3.3"
336
+ ip_protocol = "tcp"
337
+ port_range = "80,8080"
338
+ policy = "accept"
339
+ policy_index = 0
340
+ }
341
+ `
342
+
267
343
const testAccSecurityGroupRuleConfigSSH = `
268
344
resource "tencentcloud_security_group" "foo" {
269
345
name = "ci-temp-test-sg"
@@ -340,7 +416,7 @@ resource "tencentcloud_security_group" "foo" {
340
416
341
417
resource "tencentcloud_address_template" "templateB" {
342
418
name = "testB"
343
- addresses = ["1.1.1.1 /24", "1.1.1.0-1.1.1.1"]
419
+ addresses = ["1.1.1.0 /24", "1.1.1.0-1.1.1.1"]
344
420
}
345
421
346
422
resource "tencentcloud_address_template_group" "group"{
0 commit comments