|
| 1 | +package tencentcloud |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 7 | +) |
| 8 | + |
| 9 | +func TestAccTencentCloudTestingVpcAclRulesResource_Update(t *testing.T) { |
| 10 | + t.Parallel() |
| 11 | + resource.Test(t, resource.TestCase{ |
| 12 | + PreCheck: func() { testAccPreCheck(t) }, |
| 13 | + Providers: testAccProviders, |
| 14 | + Steps: []resource.TestStep{ |
| 15 | + { |
| 16 | + Config: testAccTestingVpcACLConfig, |
| 17 | + Check: resource.ComposeTestCheckFunc( |
| 18 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "name", "test_acl"), |
| 19 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.0", "ACCEPT#192.168.1.0/24#80#TCP"), |
| 20 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.1", "ACCEPT#192.168.1.0/24#80-90#TCP"), |
| 21 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.0", "ACCEPT#192.168.1.0/24#80#TCP"), |
| 22 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.1", "ACCEPT#192.168.1.0/24#80-90#TCP"), |
| 23 | + ), |
| 24 | + }, |
| 25 | + { |
| 26 | + Config: testAccTestingVpcACLConfigUpdate, |
| 27 | + Check: resource.ComposeTestCheckFunc( |
| 28 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "name", "test_acl"), |
| 29 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.0", "ACCEPT#192.168.1.0/24#800#TCP"), |
| 30 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.1", "ACCEPT#192.168.1.0/24#800-900#TCP"), |
| 31 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.0", "ACCEPT#192.168.1.0/24#800#TCP"), |
| 32 | + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.1", "ACCEPT#192.168.1.0/24#800-900#TCP"), |
| 33 | + ), |
| 34 | + }, |
| 35 | + }, |
| 36 | + }) |
| 37 | +} |
| 38 | + |
| 39 | +const testAccTestingVpcACLConfig = defaultVpcVariable + ` |
| 40 | +resource "tencentcloud_vpc" "foo" { |
| 41 | + name = var.instance_name |
| 42 | + cidr_block = var.vpc_cidr |
| 43 | +} |
| 44 | +resource "tencentcloud_vpc_acl" "foo" { |
| 45 | + vpc_id = tencentcloud_vpc.foo.id |
| 46 | + name = "test_acl" |
| 47 | + ingress = [ |
| 48 | + "ACCEPT#192.168.1.0/24#80#TCP", |
| 49 | + "ACCEPT#192.168.1.0/24#80-90#TCP", |
| 50 | + ] |
| 51 | + egress = [ |
| 52 | + "ACCEPT#192.168.1.0/24#80#TCP", |
| 53 | + "ACCEPT#192.168.1.0/24#80-90#TCP", |
| 54 | + ] |
| 55 | +} |
| 56 | +` |
| 57 | + |
| 58 | +const testAccTestingVpcACLConfigUpdate = defaultVpcVariable + ` |
| 59 | +resource "tencentcloud_vpc" "foo" { |
| 60 | + name = var.instance_name |
| 61 | + cidr_block = var.vpc_cidr |
| 62 | +} |
| 63 | +
|
| 64 | +resource "tencentcloud_vpc_acl" "foo" { |
| 65 | + vpc_id = tencentcloud_vpc.foo.id |
| 66 | + name = "test_acl" |
| 67 | + ingress = [ |
| 68 | + "ACCEPT#192.168.1.0/24#800#TCP", |
| 69 | + "ACCEPT#192.168.1.0/24#800-900#TCP", |
| 70 | + ] |
| 71 | + egress = [ |
| 72 | + "ACCEPT#192.168.1.0/24#800#TCP", |
| 73 | + "ACCEPT#192.168.1.0/24#800-900#TCP", |
| 74 | + ] |
| 75 | +} |
| 76 | +` |
0 commit comments