diff --git a/kong/resource_kong_consumer_jwt_auth.go b/kong/resource_kong_consumer_jwt_auth.go index 408ba06..af15d1a 100644 --- a/kong/resource_kong_consumer_jwt_auth.go +++ b/kong/resource_kong_consumer_jwt_auth.go @@ -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"), } diff --git a/kong/resource_kong_consumer_jwt_auth_test.go b/kong/resource_kong_consumer_jwt_auth_test.go index f510c21..28c0ba0 100644 --- a/kong/resource_kong_consumer_jwt_auth_test.go +++ b/kong/resource_kong_consumer_jwt_auth_test.go @@ -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"), + ), + }, }, }) } @@ -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" +} +`