@@ -61,6 +61,23 @@ func TestAccKeycloakOpenidClient_basic_with_consent(t *testing.T) {
6161 })
6262}
6363
64+ func TestAccKeycloakOpenidClient_basic_with_authorization (t * testing.T ) {
65+ t .Parallel ()
66+ clientId := acctest .RandomWithPrefix ("tf-acc" )
67+
68+ resource .Test (t , resource.TestCase {
69+ ProviderFactories : testAccProviderFactories ,
70+ PreCheck : func () { testAccPreCheck (t ) },
71+ CheckDestroy : testAccCheckKeycloakOpenidClientDestroy (),
72+ Steps : []resource.TestStep {
73+ {
74+ Config : testKeycloakOpenidClient_basic_with_authorization (clientId ),
75+ Check : testAccCheckKeycloakOpenidClientExistsWithCorrectAuthorizationSettings ("keycloak_openid_client.client" ),
76+ },
77+ },
78+ })
79+ }
80+
6481func TestAccKeycloakOpenidClient_createAfterManualDestroy (t * testing.T ) {
6582 t .Parallel ()
6683 var client = & keycloak.OpenidClient {}
@@ -814,6 +831,29 @@ func testAccCheckKeycloakOpenidClientExistsWithCorrectConsentSettings(resourceNa
814831 }
815832}
816833
834+ func testAccCheckKeycloakOpenidClientExistsWithCorrectAuthorizationSettings (resourceName string ) resource.TestCheckFunc {
835+ return func (s * terraform.State ) error {
836+ client , err := getOpenidClientFromState (s , resourceName )
837+ if err != nil {
838+ return err
839+ }
840+
841+ if client .AuthorizationSettings == nil {
842+ return fmt .Errorf ("expected openid client to have authorization settings" )
843+ }
844+
845+ if client .AuthorizationSettings .DecisionStrategy != "AFFIRMATIVE" {
846+ return fmt .Errorf ("expected openid client to have decision_strategy %v, but got %v" , "AFFIRMATIVE" , client .AuthorizationSettings .DecisionStrategy )
847+ }
848+
849+ if client .AuthorizationSettings .PolicyEnforcementMode != "ENFORCING" {
850+ return fmt .Errorf ("expected openid client to have policy_enforcement_mode %v, but got %v" , "ENFORCING" , client .AuthorizationSettings .PolicyEnforcementMode )
851+ }
852+
853+ return nil
854+ }
855+ }
856+
817857func testAccCheckKeycloakOpenidClientHasBackchannelSettings (resourceName , backchannelLogoutUrl string , backchannelLogoutSessionRequired , backchannelLogoutRevokeOfflineSessions bool ) resource.TestCheckFunc {
818858 return func (s * terraform.State ) error {
819859 client , err := getOpenidClientFromState (s , resourceName )
@@ -1284,6 +1324,31 @@ resource "keycloak_openid_client" "client" {
12841324 ` , testAccRealm .Realm , clientId )
12851325}
12861326
1327+ func testKeycloakOpenidClient_basic_with_authorization (clientId string ) string {
1328+ return fmt .Sprintf (`
1329+ data "keycloak_realm" "realm" {
1330+ realm = "%s"
1331+ }
1332+
1333+ resource "keycloak_openid_client" "client" {
1334+ client_id = "%s"
1335+ realm_id = data.keycloak_realm.realm.id
1336+ access_type = "CONFIDENTIAL"
1337+ client_authenticator_type = "client-secret"
1338+ standard_flow_enabled = false
1339+ implicit_flow_enabled = false
1340+ direct_access_grants_enabled = false
1341+ service_accounts_enabled = true
1342+
1343+ authorization {
1344+ policy_enforcement_mode = "ENFORCING"
1345+ decision_strategy = "AFFIRMATIVE"
1346+ allow_remote_resource_management = "true"
1347+ }
1348+ }
1349+ ` , testAccRealm .Realm , clientId )
1350+ }
1351+
12871352func testKeycloakOpenidClient_AccessToken_basic (clientId , accessTokenLifespan string ) string {
12881353 return fmt .Sprintf (`
12891354data "keycloak_realm" "realm" {
0 commit comments