Skip to content

Commit

Permalink
Update cognito_user_pool_client: fix Client Name updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Caussat committed Jul 22, 2019
1 parent 5f5994c commit 95752fe
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_ClientName(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
rName2 := acctest.RandomWithPrefix("tf-acc-test")

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

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_ClientName(rName string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "pool" {
name = "%s"
}
resource "aws_cognito_user_pool_client" "client" {
name = "%s"
user_pool_id = "${aws_cognito_user_pool.pool.id}"
}
`, rName, rName)
}

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

0 comments on commit 95752fe

Please sign in to comment.