From 24f034a2c634a476143ee768a9de2158cf07785f Mon Sep 17 00:00:00 2001 From: Cameron Stokes Date: Sat, 6 Feb 2016 14:00:26 -0800 Subject: [PATCH] Acc tests for aws_vpn_connection tunnel attributes. --- .../aws/resource_aws_vpn_connection_test.go | 82 ++++++++++++++----- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/builtin/providers/aws/resource_aws_vpn_connection_test.go b/builtin/providers/aws/resource_aws_vpn_connection_test.go index cf151fc854..f833a1c3a1 100644 --- a/builtin/providers/aws/resource_aws_vpn_connection_test.go +++ b/builtin/providers/aws/resource_aws_vpn_connection_test.go @@ -117,45 +117,87 @@ func testAccAwsVpnConnection( } } +func TestAccAWSVpnConnection_xmlconfig(t *testing.T) { + tunnelInfo := xmlConfigToTunnelInfo(testAccAwsVpnTunnelInfoXML) + if tunnelInfo.Tunnel1Address != "FIRST_ADDRESS" { + 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" - } + tags { + Name = "vpn_gateway" + } } resource "aws_customer_gateway" "customer_gateway" { - bgp_asn = 60000 - ip_address = "178.0.0.1" - type = "ipsec.1" + bgp_asn = 60000 + ip_address = "178.0.0.1" + type = "ipsec.1" } resource "aws_vpn_connection" "foo" { - vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" - customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}" - type = "ipsec.1" - static_routes_only = true + vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" + customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}" + type = "ipsec.1" + static_routes_only = true } ` // Change static_routes_only to be false, forcing a refresh. const testAccAwsVpnConnectionConfigUpdate = ` resource "aws_vpn_gateway" "vpn_gateway" { - tags { - Name = "vpn_gateway" - } + tags { + Name = "vpn_gateway" + } } resource "aws_customer_gateway" "customer_gateway" { - bgp_asn = 60000 - ip_address = "178.0.0.1" - type = "ipsec.1" + bgp_asn = 60000 + ip_address = "178.0.0.1" + type = "ipsec.1" } resource "aws_vpn_connection" "foo" { - vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" - customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}" - type = "ipsec.1" - static_routes_only = false + vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" + customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}" + type = "ipsec.1" + static_routes_only = false } ` + +// Test our VPN tunnel config XML parsing +const testAccAwsVpnTunnelInfoXML = ` + + + + + SECOND_ADDRESS + + + + SECOND_KEY + + + + + + FIRST_ADDRESS + + + + FIRST_KEY + + + +`