From 0fd22cf29e3a4c6cfa7d2739cfd1b94424cfe043 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 9 Feb 2018 15:43:01 -0500 Subject: [PATCH 1/3] test/resource/aws_sns_platform_application: Support APNS private key and certificate file contents --- ...ource_aws_sns_platform_application_test.go | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/aws/resource_aws_sns_platform_application_test.go b/aws/resource_aws_sns_platform_application_test.go index c26eb6192f3..1bbf21d9199 100644 --- a/aws/resource_aws_sns_platform_application_test.go +++ b/aws/resource_aws_sns_platform_application_test.go @@ -6,6 +6,8 @@ import ( "log" "os" "regexp" + "strconv" + "strings" "testing" "github.com/hashicorp/terraform/helper/acctest" @@ -37,7 +39,20 @@ type testAccAwsSnsPlatformApplicationPlatform struct { func testAccAwsSnsPlatformApplicationPlatformFromEnv(t *testing.T) []*testAccAwsSnsPlatformApplicationPlatform { platforms := make([]*testAccAwsSnsPlatformApplicationPlatform, 0, 2) - if os.Getenv("APNS_SANDBOX_CREDENTIAL_PATH") != "" { + if os.Getenv("APNS_SANDBOX_CREDENTIAL") != "" { + if os.Getenv("APNS_SANDBOX_PRINCIPAL") == "" { + t.Fatalf("APNS_SANDBOX_CREDENTIAL set but missing APNS_SANDBOX_PRINCIPAL") + } + + platform := &testAccAwsSnsPlatformApplicationPlatform{ + Name: "APNS_SANDBOX", + Credential: fmt.Sprintf("< Date: Fri, 9 Feb 2018 15:47:14 -0500 Subject: [PATCH 2/3] test/resource/aws_sns_platform_application: Ensure we now quote APNS file paths too --- aws/resource_aws_sns_platform_application_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_sns_platform_application_test.go b/aws/resource_aws_sns_platform_application_test.go index 1bbf21d9199..78d52152831 100644 --- a/aws/resource_aws_sns_platform_application_test.go +++ b/aws/resource_aws_sns_platform_application_test.go @@ -67,9 +67,9 @@ func testAccAwsSnsPlatformApplicationPlatformFromEnv(t *testing.T) []*testAccAws platform := &testAccAwsSnsPlatformApplicationPlatform{ Name: "APNS_SANDBOX", - Credential: fmt.Sprintf("${file(pathexpand(%q))}", os.Getenv("APNS_SANDBOX_CREDENTIAL_PATH")), + Credential: strconv.Quote(fmt.Sprintf("${file(pathexpand(%q))}", os.Getenv("APNS_SANDBOX_CREDENTIAL_PATH"))), CredentialHash: credentialHash, - Principal: fmt.Sprintf("${file(pathexpand(%q))}", os.Getenv("APNS_SANDBOX_PRINCIPAL_PATH")), + Principal: strconv.Quote(fmt.Sprintf("${file(pathexpand(%q))}", os.Getenv("APNS_SANDBOX_PRINCIPAL_PATH"))), PrincipalHash: principalHash, } platforms = append(platforms, platform) From bf818b5cd00038ebcf881f42b97a22c69349b628 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 9 Feb 2018 17:00:23 -0500 Subject: [PATCH 3/3] test/resource/aws_sns_platform_application: Remove explicit hash value checking --- ...ource_aws_sns_platform_application_test.go | 55 +++++-------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/aws/resource_aws_sns_platform_application_test.go b/aws/resource_aws_sns_platform_application_test.go index 78d52152831..f86bebbc1f6 100644 --- a/aws/resource_aws_sns_platform_application_test.go +++ b/aws/resource_aws_sns_platform_application_test.go @@ -2,7 +2,6 @@ package aws import ( "fmt" - "io/ioutil" "log" "os" "regexp" @@ -13,7 +12,6 @@ import ( "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - homedir "github.com/mitchellh/go-homedir" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/sns" @@ -29,11 +27,9 @@ import ( **/ type testAccAwsSnsPlatformApplicationPlatform struct { - Name string - Credential string - CredentialHash string - Principal string - PrincipalHash string + Name string + Credential string + Principal string } func testAccAwsSnsPlatformApplicationPlatformFromEnv(t *testing.T) []*testAccAwsSnsPlatformApplicationPlatform { @@ -45,41 +41,28 @@ func testAccAwsSnsPlatformApplicationPlatformFromEnv(t *testing.T) []*testAccAws } platform := &testAccAwsSnsPlatformApplicationPlatform{ - Name: "APNS_SANDBOX", - Credential: fmt.Sprintf("<