Skip to content

Commit

Permalink
Merge branch 'jorcau-cognito_user_pool_client_fix_client_name_update'
Browse files Browse the repository at this point in the history
  • Loading branch information
bflad committed Jul 23, 2019
2 parents 1cee64e + e6d37b6 commit 3717439
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aws/resource_aws_cognito_user_pool_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ func resourceAwsCognitoUserPoolClientUpdate(d *schema.ResourceData, meta interfa
UserPoolId: aws.String(d.Get("user_pool_id").(string)),
}

if v, ok := d.GetOk("name"); ok {
params.ClientName = aws.String(v.(string))
}

if v, ok := d.GetOk("explicit_auth_flows"); ok {
params.ExplicitAuthFlows = expandStringList(v.(*schema.Set).List())
}
Expand Down
40 changes: 40 additions & 0 deletions aws/resource_aws_cognito_user_pool_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ func TestAccAWSCognitoUserPoolClient_RefreshTokenValidity(t *testing.T) {
})
}

func TestAccAWSCognitoUserPoolClient_Name(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_cognito_user_pool_client.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSCognitoIdentityProvider(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCognitoUserPoolClientDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCognitoUserPoolClientConfig_Name(rName, "name1"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolClientExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", "name1"),
),
},
{
Config: testAccAWSCognitoUserPoolClientConfig_Name(rName, "name2"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolClientExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", "name2"),
),
},
},
})
}

func TestAccAWSCognitoUserPoolClient_allFields(t *testing.T) {
userPoolName := fmt.Sprintf("tf-acc-cognito-user-pool-%s", acctest.RandString(7))
clientName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down Expand Up @@ -287,6 +314,19 @@ resource "aws_cognito_user_pool_client" "client" {
`, rName, rName, refreshTokenValidity)
}

func testAccAWSCognitoUserPoolClientConfig_Name(rName, name string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "test" {
name = %[1]q
}
resource "aws_cognito_user_pool_client" "test" {
name = %[2]q
user_pool_id = "${aws_cognito_user_pool.test.id}"
}
`, rName, name)
}

func testAccAWSCognitoUserPoolClientConfig_allFields(userPoolName, clientName string, refreshTokenValidity int) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "pool" {
Expand Down

0 comments on commit 3717439

Please sign in to comment.