Skip to content

Commit

Permalink
update rsa_public_key of jwt consumer is nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoneto-senior committed Sep 15, 2023
1 parent e73f90e commit 4233714
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kong/resource_kong_consumer_jwt_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ func resourceKongConsumerJWTAuthUpdate(ctx context.Context, d *schema.ResourceDa

JWTAuthRequest := &kong.JWTAuth{
ID: kong.String(id.ID),
Algorithm: kong.String(d.Get("algorithm").(string)),
Key: kong.String(d.Get("key").(string)),
RSAPublicKey: kong.String(d.Get("rsa_public_key").(string)),
Secret: kong.String(d.Get("secret").(string)),
Algorithm: readStringPtrFromResource(d, "algorithm"),
Key: readStringPtrFromResource(d, "key"),
RSAPublicKey: readStringPtrFromResource(d, "rsa_public_key"),
Secret: readStringPtrFromResource(d, "secret"),
Tags: readStringArrayPtrFromResource(d, "tags"),
}

Expand Down
23 changes: 23 additions & 0 deletions kong/resource_kong_consumer_jwt_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ func TestAccJWTAuth(t *testing.T) {
),
ExpectNonEmptyPlan: true,
},
{
Config: testCreateJWTAuthConfigDefaultsUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckJWTAuthExists("kong_consumer_jwt_auth.consumer_jwt_config_defaults"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config_defaults", "algorithm", "HS256"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config_defaults", "key", "updated_key"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config_defaults", "secret", "updated_secret"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config_defaults", "tags.#", "0"),
),
},
},
})
}
Expand Down Expand Up @@ -189,3 +199,16 @@ resource "kong_consumer_jwt_auth" "consumer_jwt_config_defaults" {
consumer_id = "${kong_consumer.consumer_jwt_defaults.id}"
}
`
const testCreateJWTAuthConfigDefaultsUpdate = `
resource "kong_consumer" "consumer_jwt_defaults" {
username = "consumer_jwt"
custom_id = "666"
}
resource "kong_consumer_jwt_auth" "consumer_jwt_config_defaults" {
consumer_id = "${kong_consumer.consumer_jwt_defaults.id}"
algorithm = "HS256"
key = "updated_key"
secret = "updated_secret"
}
`

0 comments on commit 4233714

Please sign in to comment.