-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add email sending account #8626
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"errors" | ||
"fmt" | ||
"log" | ||
"os" | ||
"regexp" | ||
"testing" | ||
|
||
|
@@ -270,23 +271,33 @@ func TestAccAWSCognitoUserPool_withSmsVerificationMessage(t *testing.T) { | |
|
||
func TestAccAWSCognitoUserPool_withEmailConfiguration(t *testing.T) { | ||
name := acctest.RandString(5) | ||
replyTo := fmt.Sprintf("tf-acc-reply-%[email protected]", name) | ||
|
||
sourceARN, ok := os.LookupEnv("TEST_AWS_SES_VERIFIED_EMAIL_ARN") | ||
if !ok { | ||
t.Skip("'TEST_AWS_SES_VERIFIED_EMAIL_ARN' not set, skipping test.") | ||
} | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCognitoIdentityProvider(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSCognitoUserPoolDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSCognitoUserPoolConfig_basic(name), | ||
Config: testAccAWSCognitoUserPoolConfig_withEmailConfiguration(name, "", "", "COGNITO_DEFAULT"), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckAWSCognitoUserPoolExists("aws_cognito_user_pool.pool"), | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.#", "1"), | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.reply_to_email_address", ""), | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.email_sending_account", "COGNITO_DEFAULT"), | ||
), | ||
}, | ||
{ | ||
Config: testAccAWSCognitoUserPoolConfig_withEmailConfiguration(name), | ||
Config: testAccAWSCognitoUserPoolConfig_withEmailConfiguration(name, replyTo, sourceARN, "DEVELOPER"), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.#", "1"), | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.reply_to_email_address", "foo.bar@baz"), | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.reply_to_email_address", replyTo), | ||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.email_sending_account", "DEVELOPER"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks we need a slight more involved tests to handle this check as the tests require a verified SES email ARN in order to work as expected. Trying replacing the existing test func TestAccAWSCognitoUserPool_EmailConfiguration(t *testing.T) {
name := acctest.RandString(5)
replyTo := fmt.Sprintf("tf-acc-reply-%[email protected]", name)
sourceARN, ok := os.LookupEnv("TEST_AWS_SES_VERIFIED_EMAIL_ARN")
if !ok {
t.Skip("'TEST_AWS_SES_VERIFIED_EMAIL_ARN' not set, skipping test.")
}
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCognitoUserPoolDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCognitoUserPoolConfig_basic(name),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolExists("aws_cognito_user_pool.pool"),
),
},
{
Config: testAccAWSCognitoUserPoolConfig_withEmailConfiguration(name, replyTo, sourceARN, "DEVELOPER"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.#", "1"),
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.reply_to_email_address", replyTo),
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.email_sending_account", "DEVELOPER"),
),
},
},
})
} |
||
resource.TestCheckResourceAttr("aws_cognito_user_pool.pool", "email_configuration.0.source_arn", sourceARN), | ||
), | ||
}, | ||
}, | ||
|
@@ -857,16 +868,18 @@ resource "aws_cognito_user_pool" "pool" { | |
`, name) | ||
} | ||
|
||
func testAccAWSCognitoUserPoolConfig_withEmailConfiguration(name string) string { | ||
func testAccAWSCognitoUserPoolConfig_withEmailConfiguration(name, email, arn, account string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_cognito_user_pool" "pool" { | ||
name = "terraform-test-pool-%s" | ||
name = "terraform-test-pool-%[1]s" | ||
|
||
email_configuration { | ||
reply_to_email_address = "foo.bar@baz" | ||
} | ||
} | ||
`, name) | ||
|
||
email_configuration { | ||
reply_to_email_address = %[2]q | ||
source_arn = %[3]q | ||
email_sending_account = %[4]q | ||
} | ||
}`, name, email, arn, account) | ||
} | ||
|
||
func testAccAWSCognitoUserPoolConfig_withSmsConfiguration(name string) string { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2465,32 +2465,6 @@ func TestValidateKmsKey(t *testing.T) { | |
} | ||
} | ||
|
||
func TestValidateCognitoUserPoolReplyEmailAddress(t *testing.T) { | ||
validTypes := []string{ | ||
"[email protected]", | ||
"foo@bar", | ||
"foo [email protected]", | ||
"[email protected]", | ||
} | ||
for _, v := range validTypes { | ||
_, errors := validateCognitoUserPoolReplyEmailAddress(v, "name") | ||
if len(errors) != 0 { | ||
t.Fatalf("%q should be a valid Cognito User Pool Reply Email Address: %q", v, errors) | ||
} | ||
} | ||
|
||
invalidTypes := []string{ | ||
"foo", | ||
"@bar.baz", | ||
} | ||
for _, v := range invalidTypes { | ||
_, errors := validateCognitoUserPoolReplyEmailAddress(v, "name") | ||
if len(errors) == 0 { | ||
t.Fatalf("%q should be an invalid Cognito User Pool Reply Email Address", v) | ||
} | ||
} | ||
} | ||
|
||
func TestResourceAWSElastiCacheReplicationGroupAuthTokenValidation(t *testing.T) { | ||
cases := []struct { | ||
Value string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to get our testing working I added
""
as a valid value in the validation function.