Skip to content

Commit

Permalink
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 eca3fc4 commit 489c079
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion kong/resource_kong_consumer_jwt_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func resourceKongConsumerJWTAuthCreate(ctx context.Context, d *schema.ResourceDa
JWTAuthRequest := &kong.JWTAuth{
Algorithm: kong.String(d.Get("algorithm").(string)),
Key: kong.String(d.Get("key").(string)),
RSAPublicKey: kong.String(d.Get("rsa_public_key").(string)),
RSAPublicKey: readStringPtrFromResource(d, "rsa_public_key"),
Secret: kong.String(d.Get("secret").(string)),
Tags: readStringArrayPtrFromResource(d, "tags"),
}
Expand Down
31 changes: 11 additions & 20 deletions kong/resource_kong_consumer_jwt_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ func TestAccJWTAuth(t *testing.T) {
{
Config: testCreateJWTAuthConfigRsaPublicKeyNull,
Check: resource.ComposeTestCheckFunc(
testAccCheckJWTAuthExists("kong_consumer_jwt_auth.consumer_jwt_config"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "algorithm", "HS256"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "key", "my_key"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "secret", "my_secret"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "rsa_public_key", ""),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "tags.#", "2"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "tags.0", "foo"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config", "tags.1", "bar"),
testAccCheckJWTAuthExists("kong_consumer_jwt_auth.consumer_jwt_config2"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "algorithm", "HS256"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "key", "my_key"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "secret", "my_secret"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "rsa_public_key", ""),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "tags.#", "2"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "tags.0", "foo"),
resource.TestCheckResourceAttr("kong_consumer_jwt_auth.consumer_jwt_config2", "tags.1", "bar"),
),
},
},
Expand Down Expand Up @@ -180,22 +180,13 @@ resource "kong_consumer_jwt_auth" "consumer_jwt_config" {
}
`
const testCreateJWTAuthConfigRsaPublicKeyNull = `
resource "kong_consumer" "my_consumer" {
resource "kong_consumer" "my_consumer2" {
username = "User2"
custom_id = "456"
}
resource "kong_plugin" "jwt_plugin" {
name = "jwt2"
config_json = <<EOT
{
"claims_to_verify": ["exp"]
}
EOT
}
resource "kong_consumer_jwt_auth" "consumer_jwt_config" {
consumer_id = "${kong_consumer.my_consumer.id}"
resource "kong_consumer_jwt_auth" "consumer_jwt_config2" {
consumer_id = "${kong_consumer.my_consumer2.id}"
algorithm = "HS256"
key = "my_key"
secret = "my_secret"
Expand Down

0 comments on commit 489c079

Please sign in to comment.