Skip to content
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

Updating regex and test to comply with AWS Documentation #15773

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aws/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -1517,8 +1517,8 @@ func validateAwsKmsGrantName(v interface{}, k string) (ws []string, es []error)

func validateCognitoIdentityPoolName(v interface{}, k string) (ws []string, errors []error) {
val := v.(string)
if !regexp.MustCompile(`^[\w _]+$`).MatchString(val) {
errors = append(errors, fmt.Errorf("%q must contain only alphanumeric characters and spaces", k))
if !regexp.MustCompile(`^[\w\s+=,.@-]+$`).MatchString(val) {
errors = append(errors, fmt.Errorf("%q must contain only alphanumeric characters, dots, underscores and hyphens", k))
}

return
Expand Down
11 changes: 6 additions & 5 deletions aws/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,8 @@ func TestValidateCognitoIdentityPoolName(t *testing.T) {
"foo bar",
"foo_bar",
"1foo 2bar 3",
"foo-bar_123",
"foo-bar",
}

for _, s := range validValues {
Expand All @@ -2013,11 +2015,10 @@ func TestValidateCognitoIdentityPoolName(t *testing.T) {
}

invalidValues := []string{
"1-2-3",
"foo!",
"foo-bar",
"foo-bar",
"foo1-bar2",
"foo*",
"foo:bar",
"foo&bar",
"foo1^bar2",
}

for _, s := range invalidValues {
Expand Down