Skip to content

Commit dc2456a

Browse files
Mikhail PutilovMikhail Putilov
authored andcommitted
Do not delete the "account" client in the acceptance test because it is undeletable (KeyCloak returns http status 400)
Terraform acceptance test library simply can't handle this situation. One way that I found to overcome this is to replace the `DeleteContext` function in acceptance tests only. I believe we must not alter the behavior of the standard response of KeyCloak when a client is deleted, nor hide that fact that KeyCloak response is 400 in the production code. Signed-off-by: Mikhail Putilov <[email protected]>
1 parent 64ffb63 commit dc2456a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

provider/provider_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99
"time"
1010

11+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1112
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1213
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1314
"github.com/hashicorp/terraform-plugin-sdk/v2/meta"
@@ -41,6 +42,15 @@ func init() {
4142
panic(err)
4243
}
4344
testAccProvider = KeycloakProvider(keycloakClient)
45+
46+
testAccProvider.ResourcesMap["keycloak_openid_client"].DeleteContext = func(ctx context.Context, data *schema.ResourceData, i interface{}) diag.Diagnostics {
47+
if data.State().Attributes["client_id"] == "account" {
48+
return diag.Diagnostics{}
49+
} else {
50+
return resourceKeycloakOpenidClientDelete(ctx, data, i)
51+
}
52+
}
53+
4454
testAccProviderFactories = map[string]func() (*schema.Provider, error){
4555
"keycloak": func() (*schema.Provider, error) {
4656
return testAccProvider, nil

0 commit comments

Comments
 (0)