Skip to content

Commit 24f034a

Browse files
committed
Acc tests for aws_vpn_connection tunnel attributes.
1 parent a239a2a commit 24f034a

1 file changed

Lines changed: 62 additions & 20 deletions

File tree

‎builtin/providers/aws/resource_aws_vpn_connection_test.go‎

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,45 +117,87 @@ func testAccAwsVpnConnection(
117117
}
118118
}
119119

120+
func TestAccAWSVpnConnection_xmlconfig(t *testing.T) {
121+
tunnelInfo := xmlConfigToTunnelInfo(testAccAwsVpnTunnelInfoXML)
122+
if tunnelInfo.Tunnel1Address != "FIRST_ADDRESS" {
123+
t.Fatalf("First address from tunnel XML was incorrect.")
124+
}
125+
if tunnelInfo.Tunnel1PreSharedKey != "FIRST_KEY" {
126+
t.Fatalf("First key from tunnel XML was incorrect.")
127+
}
128+
if tunnelInfo.Tunnel2Address != "SECOND_ADDRESS" {
129+
t.Fatalf("Second address from tunnel XML was incorrect.")
130+
}
131+
if tunnelInfo.Tunnel2PreSharedKey != "SECOND_KEY" {
132+
t.Fatalf("Second key from tunnel XML was incorrect.")
133+
}
134+
}
135+
120136
const testAccAwsVpnConnectionConfig = `
121137
resource "aws_vpn_gateway" "vpn_gateway" {
122-
tags {
123-
Name = "vpn_gateway"
124-
}
138+
tags {
139+
Name = "vpn_gateway"
140+
}
125141
}
126142
127143
resource "aws_customer_gateway" "customer_gateway" {
128-
bgp_asn = 60000
129-
ip_address = "178.0.0.1"
130-
type = "ipsec.1"
144+
bgp_asn = 60000
145+
ip_address = "178.0.0.1"
146+
type = "ipsec.1"
131147
}
132148
133149
resource "aws_vpn_connection" "foo" {
134-
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
135-
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
136-
type = "ipsec.1"
137-
static_routes_only = true
150+
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
151+
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
152+
type = "ipsec.1"
153+
static_routes_only = true
138154
}
139155
`
140156

141157
// Change static_routes_only to be false, forcing a refresh.
142158
const testAccAwsVpnConnectionConfigUpdate = `
143159
resource "aws_vpn_gateway" "vpn_gateway" {
144-
tags {
145-
Name = "vpn_gateway"
146-
}
160+
tags {
161+
Name = "vpn_gateway"
162+
}
147163
}
148164
149165
resource "aws_customer_gateway" "customer_gateway" {
150-
bgp_asn = 60000
151-
ip_address = "178.0.0.1"
152-
type = "ipsec.1"
166+
bgp_asn = 60000
167+
ip_address = "178.0.0.1"
168+
type = "ipsec.1"
153169
}
154170
155171
resource "aws_vpn_connection" "foo" {
156-
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
157-
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
158-
type = "ipsec.1"
159-
static_routes_only = false
172+
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
173+
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
174+
type = "ipsec.1"
175+
static_routes_only = false
160176
}
161177
`
178+
179+
// Test our VPN tunnel config XML parsing
180+
const testAccAwsVpnTunnelInfoXML = `
181+
<vpn_connection id="vpn-abc123">
182+
<ipsec_tunnel>
183+
<vpn_gateway>
184+
<tunnel_outside_address>
185+
<ip_address>SECOND_ADDRESS</ip_address>
186+
</tunnel_outside_address>
187+
</vpn_gateway>
188+
<ike>
189+
<pre_shared_key>SECOND_KEY</pre_shared_key>
190+
</ike>
191+
</ipsec_tunnel>
192+
<ipsec_tunnel>
193+
<vpn_gateway>
194+
<tunnel_outside_address>
195+
<ip_address>FIRST_ADDRESS</ip_address>
196+
</tunnel_outside_address>
197+
</vpn_gateway>
198+
<ike>
199+
<pre_shared_key>FIRST_KEY</pre_shared_key>
200+
</ike>
201+
</ipsec_tunnel>
202+
</vpn_connection>
203+
`

0 commit comments

Comments
 (0)