Acc tests for aws_vpn_connection tunnel attributes.

This commit is contained in:
Cameron Stokes 2016-02-06 14:00:26 -08:00
parent a239a2a125
commit 24f034a2c6
1 changed files with 63 additions and 21 deletions

View File

@ -117,45 +117,87 @@ func testAccAwsVpnConnection(
} }
} }
const testAccAwsVpnConnectionConfig = ` func TestAccAWSVpnConnection_xmlconfig(t *testing.T) {
resource "aws_vpn_gateway" "vpn_gateway" { tunnelInfo := xmlConfigToTunnelInfo(testAccAwsVpnTunnelInfoXML)
tags { if tunnelInfo.Tunnel1Address != "FIRST_ADDRESS" {
Name = "vpn_gateway" t.Fatalf("First address from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel1PreSharedKey != "FIRST_KEY" {
t.Fatalf("First key from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel2Address != "SECOND_ADDRESS" {
t.Fatalf("Second address from tunnel XML was incorrect.")
}
if tunnelInfo.Tunnel2PreSharedKey != "SECOND_KEY" {
t.Fatalf("Second key from tunnel XML was incorrect.")
} }
} }
const testAccAwsVpnConnectionConfig = `
resource "aws_vpn_gateway" "vpn_gateway" {
tags {
Name = "vpn_gateway"
}
}
resource "aws_customer_gateway" "customer_gateway" { resource "aws_customer_gateway" "customer_gateway" {
bgp_asn = 60000 bgp_asn = 60000
ip_address = "178.0.0.1" ip_address = "178.0.0.1"
type = "ipsec.1" type = "ipsec.1"
} }
resource "aws_vpn_connection" "foo" { resource "aws_vpn_connection" "foo" {
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}" customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
type = "ipsec.1" type = "ipsec.1"
static_routes_only = true static_routes_only = true
} }
` `
// Change static_routes_only to be false, forcing a refresh. // Change static_routes_only to be false, forcing a refresh.
const testAccAwsVpnConnectionConfigUpdate = ` const testAccAwsVpnConnectionConfigUpdate = `
resource "aws_vpn_gateway" "vpn_gateway" { resource "aws_vpn_gateway" "vpn_gateway" {
tags { tags {
Name = "vpn_gateway" Name = "vpn_gateway"
} }
} }
resource "aws_customer_gateway" "customer_gateway" { resource "aws_customer_gateway" "customer_gateway" {
bgp_asn = 60000 bgp_asn = 60000
ip_address = "178.0.0.1" ip_address = "178.0.0.1"
type = "ipsec.1" type = "ipsec.1"
} }
resource "aws_vpn_connection" "foo" { resource "aws_vpn_connection" "foo" {
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}" customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
type = "ipsec.1" type = "ipsec.1"
static_routes_only = false static_routes_only = false
} }
` `
// Test our VPN tunnel config XML parsing
const testAccAwsVpnTunnelInfoXML = `
<vpn_connection id="vpn-abc123">
<ipsec_tunnel>
<vpn_gateway>
<tunnel_outside_address>
<ip_address>SECOND_ADDRESS</ip_address>
</tunnel_outside_address>
</vpn_gateway>
<ike>
<pre_shared_key>SECOND_KEY</pre_shared_key>
</ike>
</ipsec_tunnel>
<ipsec_tunnel>
<vpn_gateway>
<tunnel_outside_address>
<ip_address>FIRST_ADDRESS</ip_address>
</tunnel_outside_address>
</vpn_gateway>
<ike>
<pre_shared_key>FIRST_KEY</pre_shared_key>
</ike>
</ipsec_tunnel>
</vpn_connection>
`