Skip to content

Commit 32c2d08

Browse files
tongyimingmikatong
and
mikatong
authored
fix vpn ccn unittest (#2907)
Co-authored-by: mikatong <[email protected]>
1 parent 3010ef8 commit 32c2d08

8 files changed

+354
-26
lines changed

tencentcloud/services/ccn/resource_tc_ccn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func resourceTencentCloudCcnUpdate(d *schema.ResourceData, meta interface{}) err
266266

267267
if d.HasChange("description") {
268268
if temp, ok := d.GetOk("description"); ok {
269-
request.CcnName = helper.String(temp.(string))
269+
request.CcnDescription = helper.String(temp.(string))
270270
}
271271

272272
change = true

tencentcloud/services/ccn/resource_tc_ccn_routes_test.go

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,106 @@ func TestAccTencentCloudCcnRoutesResource_basic(t *testing.T) {
2828
),
2929
},
3030
{
31-
ResourceName: "tencentcloud_ccn_routes.ccn_routes",
32-
ImportState: true,
33-
ImportStateVerify: true,
31+
ResourceName: "tencentcloud_ccn_routes.ccn_routes",
32+
ImportState: true,
3433
},
3534
},
3635
})
3736
}
3837

3938
const testAccVpcCcnRoutes = `
39+
resource "tencentcloud_ccn" "ccn" {
40+
name = "tf-test-routes"
41+
description = "tf-test-routes-des"
42+
qos = "AG"
43+
}
44+
45+
resource "tencentcloud_ccn_route_table" "table" {
46+
ccn_id = tencentcloud_ccn.ccn.id
47+
name = "tf-test-routes"
48+
description = "desc."
49+
}
50+
51+
data "tencentcloud_availability_zones" "zones" {}
52+
53+
resource "tencentcloud_vpc" "vpc" {
54+
name = "vpc-ccn-routes"
55+
cidr_block = "10.0.0.0/16"
56+
}
57+
58+
resource "tencentcloud_subnet" "subnet" {
59+
vpc_id = tencentcloud_vpc.vpc.id
60+
name = "subnet-ccn-routes"
61+
cidr_block = "10.0.0.0/16"
62+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
63+
is_multicast = false
64+
}
65+
66+
resource "tencentcloud_ccn_attachment" "attachment" {
67+
ccn_id = tencentcloud_ccn.ccn.id
68+
instance_type = "VPC"
69+
instance_id = tencentcloud_vpc.vpc.id
70+
instance_region = "ap-guangzhou"
71+
route_table_id = tencentcloud_ccn_route_table.table.id
72+
}
73+
74+
data "tencentcloud_ccn_routes" "routes" {
75+
ccn_id = tencentcloud_ccn.ccn.id
76+
depends_on = [tencentcloud_ccn_attachment.attachment]
77+
}
4078
4179
resource "tencentcloud_ccn_routes" "ccn_routes" {
42-
ccn_id = "ccn-0bbkedsb"
43-
route_id = "ccnr-9sqye2qg"
80+
ccn_id = tencentcloud_ccn.ccn.id
81+
route_id = data.tencentcloud_ccn_routes.routes.route_list.0.route_id
4482
switch = "off"
4583
}
4684
4785
`
4886

4987
const testAccVpcCcnRoutesUpdate = `
88+
resource "tencentcloud_ccn" "ccn" {
89+
name = "tf-test-routes"
90+
description = "tf-test-routes-des"
91+
qos = "AG"
92+
}
93+
94+
resource "tencentcloud_ccn_route_table" "table" {
95+
ccn_id = tencentcloud_ccn.ccn.id
96+
name = "tf-test-routes"
97+
description = "desc."
98+
}
99+
100+
data "tencentcloud_availability_zones" "zones" {}
101+
102+
resource "tencentcloud_vpc" "vpc" {
103+
name = "vpc-ccn-routes"
104+
cidr_block = "10.0.0.0/16"
105+
}
106+
107+
resource "tencentcloud_subnet" "subnet" {
108+
vpc_id = tencentcloud_vpc.vpc.id
109+
name = "subnet-ccn-routes"
110+
cidr_block = "10.0.0.0/16"
111+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
112+
is_multicast = false
113+
}
114+
115+
resource "tencentcloud_ccn_attachment" "attachment" {
116+
ccn_id = tencentcloud_ccn.ccn.id
117+
instance_type = "VPC"
118+
instance_id = tencentcloud_vpc.vpc.id
119+
instance_region = "ap-guangzhou"
120+
route_table_id = tencentcloud_ccn_route_table.table.id
121+
}
122+
123+
data "tencentcloud_ccn_routes" "routes" {
124+
ccn_id = tencentcloud_ccn.ccn.id
125+
depends_on = [tencentcloud_ccn_attachment.attachment]
126+
}
50127
51128
resource "tencentcloud_ccn_routes" "ccn_routes" {
52-
ccn_id = "ccn-0bbkedsb"
53-
route_id = "ccnr-9sqye2qg"
129+
ccn_id = tencentcloud_ccn.ccn.id
130+
route_id = data.tencentcloud_ccn_routes.routes.route_list.0.route_id
54131
switch = "on"
55132
}
56133

tencentcloud/services/vpn/data_source_tc_vpn_default_health_check_ip_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,22 @@ func TestAccTencentCloudVpnDefaultHealthCheckIpDataSource_basic(t *testing.T) {
2626

2727
const testAccVpnDefaultHealthCheckIpDataSource = `
2828
29+
data "tencentcloud_vpc_instances" "foo" {
30+
name = "Default-VPC"
31+
}
32+
33+
resource "tencentcloud_vpn_gateway" "my_cgw" {
34+
name = "terraform_test_health_check"
35+
vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id
36+
bandwidth = 10
37+
38+
tags = {
39+
test = "tf"
40+
}
41+
}
42+
2943
data "tencentcloud_vpn_default_health_check_ip" "default_health_check_ip" {
30-
vpn_gateway_id = "vpngw-gt8bianl"
44+
vpn_gateway_id = tencentcloud_vpn_gateway.my_cgw.id
3145
}
3246
3347
`

tencentcloud/services/vpn/resource_tc_vpn_connection.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ func ResourceTencentCloudVpnConnection() *schema.Resource {
136136
"ike_local_fqdn_name": {
137137
Type: schema.TypeString,
138138
Optional: true,
139+
Computed: true,
139140
ConflictsWith: []string{"ike_local_address"},
140141
Description: "Local FQDN name of the IKE operation specification.",
141142
},
142143
"ike_remote_fqdn_name": {
143144
Type: schema.TypeString,
144145
Optional: true,
146+
Computed: true,
145147
ConflictsWith: []string{"ike_remote_address"},
146148
Description: "Remote FQDN name of the IKE operation specification.",
147149
},

tencentcloud/services/vpn/resource_tc_vpn_connection_reset_test.go

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,65 @@ func TestAccTencentCloudVpnConnectionResetResource_basic(t *testing.T) {
2525
}
2626

2727
const testAccVpnConnectionReset = `
28+
resource "tencentcloud_vpn_customer_gateway" "cgw" {
29+
name = "terraform_test_reset"
30+
public_ip_address = "1.3.3.3"
31+
32+
}
33+
34+
# Create VPC and Subnet
35+
data "tencentcloud_vpc_instances" "foo" {
36+
name = "Default-VPC"
37+
}
38+
39+
resource "tencentcloud_vpn_gateway" "vpn" {
40+
name = "terraform_test_reset"
41+
vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id
42+
bandwidth = 5
43+
zone = "ap-guangzhou-3"
44+
45+
tags = {
46+
test = "test"
47+
}
48+
}
49+
resource "tencentcloud_vpn_connection" "connection" {
50+
name = "vpn_connection_test_reset"
51+
vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id
52+
vpn_gateway_id = tencentcloud_vpn_gateway.vpn.id
53+
customer_gateway_id = tencentcloud_vpn_customer_gateway.cgw.id
54+
pre_share_key = "test"
55+
ike_proto_encry_algorithm = "3DES-CBC"
56+
ike_proto_authen_algorithm = "MD5"
57+
ike_local_identity = "ADDRESS"
58+
ike_local_address = tencentcloud_vpn_gateway.vpn.public_ip_address
59+
ike_remote_identity = "ADDRESS"
60+
ike_remote_address = tencentcloud_vpn_customer_gateway.cgw.public_ip_address
61+
ike_dh_group_name = "GROUP1"
62+
ike_sa_lifetime_seconds = 86400
63+
ike_version = "IKEV1"
64+
ipsec_encrypt_algorithm = "3DES-CBC"
65+
ipsec_integrity_algorithm = "MD5"
66+
ipsec_sa_lifetime_seconds = 3600
67+
ipsec_pfs_dh_group = "DH-GROUP1"
68+
ipsec_sa_lifetime_traffic = 2560
69+
dpd_enable = 1
70+
dpd_timeout = "30"
71+
dpd_action = "clear"
72+
security_group_policy {
73+
local_cidr_block = "172.16.0.0/16"
74+
remote_cidr_block = ["3.3.3.0/32", ]
75+
}
76+
tags = {
77+
test = "test"
78+
}
79+
enable_health_check = true
80+
health_check_local_ip = "192.168.0.2"
81+
health_check_remote_ip = "3.3.3.2"
82+
}
2883
2984
resource "tencentcloud_vpn_connection_reset" "vpn_connection_reset" {
30-
vpn_gateway_id = "vpngw-gt8bianl"
31-
vpn_connection_id = "vpnx-kme2tx8m"
85+
vpn_gateway_id = tencentcloud_vpn_gateway.vpn.id
86+
vpn_connection_id = tencentcloud_vpn_connection.connection.id
3287
}
3388
3489
`

tencentcloud/services/vpn/resource_tc_vpn_customer_gateway_configuration_download_test.go

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,65 @@ func TestAccTencentCloudVpnCustomerGatewayConfigurationDownloadResource_basic(t
2525
}
2626

2727
const testAccVpcVpnCustomerGatewayConfigurationDownload = `
28+
resource "tencentcloud_vpn_customer_gateway" "cgw" {
29+
name = "terraform_test_download"
30+
public_ip_address = "1.3.3.3"
31+
32+
}
33+
34+
# Create VPC and Subnet
35+
data "tencentcloud_vpc_instances" "foo" {
36+
name = "Default-VPC"
37+
}
38+
39+
resource "tencentcloud_vpn_gateway" "vpn" {
40+
name = "terraform_test_download"
41+
vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id
42+
bandwidth = 5
43+
zone = "ap-guangzhou-3"
44+
45+
tags = {
46+
test = "test"
47+
}
48+
}
49+
resource "tencentcloud_vpn_connection" "connection" {
50+
name = "test_download"
51+
vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id
52+
vpn_gateway_id = tencentcloud_vpn_gateway.vpn.id
53+
customer_gateway_id = tencentcloud_vpn_customer_gateway.cgw.id
54+
pre_share_key = "test"
55+
ike_proto_encry_algorithm = "3DES-CBC"
56+
ike_proto_authen_algorithm = "MD5"
57+
ike_local_identity = "ADDRESS"
58+
ike_local_address = tencentcloud_vpn_gateway.vpn.public_ip_address
59+
ike_remote_identity = "ADDRESS"
60+
ike_remote_address = tencentcloud_vpn_customer_gateway.cgw.public_ip_address
61+
ike_dh_group_name = "GROUP1"
62+
ike_sa_lifetime_seconds = 86400
63+
ike_version = "IKEV1"
64+
ipsec_encrypt_algorithm = "3DES-CBC"
65+
ipsec_integrity_algorithm = "MD5"
66+
ipsec_sa_lifetime_seconds = 3600
67+
ipsec_pfs_dh_group = "DH-GROUP1"
68+
ipsec_sa_lifetime_traffic = 2560
69+
dpd_enable = 1
70+
dpd_timeout = "30"
71+
dpd_action = "clear"
72+
security_group_policy {
73+
local_cidr_block = "172.16.0.0/16"
74+
remote_cidr_block = ["3.3.3.0/32", ]
75+
}
76+
tags = {
77+
test = "test"
78+
}
79+
enable_health_check = true
80+
health_check_local_ip = "192.168.0.2"
81+
health_check_remote_ip = "3.3.3.2"
82+
}
2883
2984
resource "tencentcloud_vpn_customer_gateway_configuration_download" "vpn_customer_gateway_configuration_download" {
30-
vpn_gateway_id = "vpngw-gt8bianl"
31-
vpn_connection_id = "vpnx-kme2tx8m"
85+
vpn_gateway_id = tencentcloud_vpn_gateway.vpn.id
86+
vpn_connection_id = tencentcloud_vpn_connection.connection.id
3287
customer_gateway_vendor {
3388
platform = "comware"
3489
software_version = "V1.0"

0 commit comments

Comments
 (0)