From ddc5e63a3bdd9399c9e5bd921c545829251743da Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Wed, 17 Jan 2018 13:24:58 +0000 Subject: [PATCH 1/2] test/aws_api_gateway_*: Fix invalid domain --- aws/resource_aws_api_gateway_base_path_mapping_test.go | 5 +++-- aws/resource_aws_api_gateway_domain_name_test.go | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_api_gateway_base_path_mapping_test.go b/aws/resource_aws_api_gateway_base_path_mapping_test.go index 2f4205a39bc..056db44f55e 100644 --- a/aws/resource_aws_api_gateway_base_path_mapping_test.go +++ b/aws/resource_aws_api_gateway_base_path_mapping_test.go @@ -7,6 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/apigateway" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -15,7 +16,7 @@ func TestAccAWSAPIGatewayBasePath_basic(t *testing.T) { var conf apigateway.BasePathMapping // Our test cert is for a wildcard on this domain - name := fmt.Sprintf("%s.tf-acc.invalid", resource.UniqueId()) + name := fmt.Sprintf("tf-acc-%s.terraformtest.com", acctest.RandString(8)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -37,7 +38,7 @@ func TestAccAWSAPIGatewayEmptyBasePath_basic(t *testing.T) { var conf apigateway.BasePathMapping // Our test cert is for a wildcard on this domain - name := fmt.Sprintf("%s.tf-acc.invalid", resource.UniqueId()) + name := fmt.Sprintf("tf-acc-%s.terraformtest.com", acctest.RandString(8)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/aws/resource_aws_api_gateway_domain_name_test.go b/aws/resource_aws_api_gateway_domain_name_test.go index d1c008a80be..5dca1907a4f 100644 --- a/aws/resource_aws_api_gateway_domain_name_test.go +++ b/aws/resource_aws_api_gateway_domain_name_test.go @@ -7,6 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/apigateway" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -15,9 +16,9 @@ func TestAccAWSAPIGatewayDomainName_basic(t *testing.T) { var conf apigateway.DomainName // Our test cert is for a wildcard on this domain - uniqueId := resource.UniqueId() - name := fmt.Sprintf("%s.tf-acc.invalid", uniqueId) - nameModified := fmt.Sprintf("test-acc.%s.tf-acc.invalid", uniqueId) + rString := acctest.RandString(8) + name := fmt.Sprintf("tf-acc-%s.terraformtest.com", rString) + nameModified := fmt.Sprintf("tf-acc-%s-modified.terraformtest.com", rString) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, From d820a44d185f4083ccd51e6d3ef6c4a6869cb771 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Wed, 17 Jan 2018 14:31:58 +0000 Subject: [PATCH 2/2] Generate key & certs on demand via TLS provider --- ..._aws_api_gateway_base_path_mapping_test.go | 35 ++-- ...source_aws_api_gateway_domain_name_test.go | 185 +++++++----------- 2 files changed, 82 insertions(+), 138 deletions(-) diff --git a/aws/resource_aws_api_gateway_base_path_mapping_test.go b/aws/resource_aws_api_gateway_base_path_mapping_test.go index 056db44f55e..9cd09b8886f 100644 --- a/aws/resource_aws_api_gateway_base_path_mapping_test.go +++ b/aws/resource_aws_api_gateway_base_path_mapping_test.go @@ -20,7 +20,7 @@ func TestAccAWSAPIGatewayBasePath_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + Providers: testAccProvidersWithTLS, CheckDestroy: testAccCheckAWSAPIGatewayBasePathDestroy(name), Steps: []resource.TestStep{ { @@ -42,7 +42,7 @@ func TestAccAWSAPIGatewayEmptyBasePath_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + Providers: testAccProvidersWithTLS, CheckDestroy: testAccCheckAWSAPIGatewayBasePathDestroy(name), Steps: []resource.TestStep{ { @@ -143,12 +143,13 @@ func testAccCheckAWSAPIGatewayBasePathDestroy(name string) resource.TestCheckFun } } -func testAccAWSAPIGatewayBasePathConfig(name string) string { +func testAccAWSAPIGatewayBasePathConfig(domainName string) string { return fmt.Sprintf(` resource "aws_api_gateway_rest_api" "test" { name = "tf-acc-apigateway-base-path-mapping" description = "Terraform Acceptance Tests" } + # API gateway won't let us deploy an empty API resource "aws_api_gateway_resource" "test" { rest_api_id = "${aws_api_gateway_rest_api.test.id}" @@ -181,17 +182,15 @@ resource "aws_api_gateway_base_path_mapping" "test" { resource "aws_api_gateway_domain_name" "test" { domain_name = "%s" certificate_name = "tf-apigateway-base-path-mapping-test" - certificate_body = <