@@ -14,7 +14,7 @@ import (
1414 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1515)
1616
17- func TestAccTencentCloudSecurityGroupRule_basic (t * testing.T ) {
17+ func TestAccTencentCloudSecurityGroupRuleResource_basic (t * testing.T ) {
1818 t .Parallel ()
1919 var sgrId string
2020
@@ -39,7 +39,46 @@ func TestAccTencentCloudSecurityGroupRule_basic(t *testing.T) {
3939 })
4040}
4141
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 ) {
4382 t .Parallel ()
4483 var sgrId string
4584
@@ -63,7 +102,7 @@ func TestAccTencentCloudSecurityGroupRule_ssh(t *testing.T) {
63102 })
64103}
65104
66- func TestAccTencentCloudSecurityGroupRule_egress (t * testing.T ) {
105+ func TestAccTencentCloudSecurityGroupRuleResource_egress (t * testing.T ) {
67106 t .Parallel ()
68107 var sgrId string
69108
@@ -88,7 +127,7 @@ func TestAccTencentCloudSecurityGroupRule_egress(t *testing.T) {
88127 })
89128}
90129
91- func TestAccTencentCloudSecurityGroupRule_sourcesgid (t * testing.T ) {
130+ func TestAccTencentCloudSecurityGroupRuleResource_sourcesgid (t * testing.T ) {
92131 t .Parallel ()
93132 var sgrId string
94133
@@ -112,7 +151,7 @@ func TestAccTencentCloudSecurityGroupRule_sourcesgid(t *testing.T) {
112151 })
113152}
114153
115- func TestAccTencentCloudSecurityGroupRule_allDrop (t * testing.T ) {
154+ func TestAccTencentCloudSecurityGroupRuleResource_allDrop (t * testing.T ) {
116155 t .Parallel ()
117156 var sgrId string
118157
@@ -136,7 +175,7 @@ func TestAccTencentCloudSecurityGroupRule_allDrop(t *testing.T) {
136175 })
137176}
138177
139- func TestAccTencentCloudSecurityGroupRule_addressTemplate (t * testing.T ) {
178+ func TestAccTencentCloudSecurityGroupRuleResource_addressTemplate (t * testing.T ) {
140179 t .Parallel ()
141180 var sgrId string
142181 resource .Test (t , resource.TestCase {
@@ -167,7 +206,7 @@ func TestAccTencentCloudSecurityGroupRule_addressTemplate(t *testing.T) {
167206 })
168207}
169208
170- func TestAccTencentCloudSecurityGroupRule_protocolTemplate (t * testing.T ) {
209+ func TestAccTencentCloudSecurityGroupRuleResource_protocolTemplate (t * testing.T ) {
171210 t .Parallel ()
172211 var sgrId string
173212 resource .Test (t , resource.TestCase {
@@ -264,6 +303,43 @@ resource "tencentcloud_security_group_rule" "http-in" {
264303}
265304`
266305
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+
267343const testAccSecurityGroupRuleConfigSSH = `
268344resource "tencentcloud_security_group" "foo" {
269345 name = "ci-temp-test-sg"
@@ -340,7 +416,7 @@ resource "tencentcloud_security_group" "foo" {
340416
341417resource "tencentcloud_address_template" "templateB" {
342418 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"]
344420}
345421
346422resource "tencentcloud_address_template_group" "group"{
0 commit comments