Fixing ClientPoliciesTest failure (#12670)

Closes #10633

Co-authored-by: wojnarfilip <fwojnar@redhat.com>
This commit is contained in:
fwojnar 2022-07-11 12:22:25 +02:00 committed by GitHub
parent 29aad9dc45
commit 7fccdb10d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ import org.keycloak.authentication.authenticators.client.ClientIdAndSecretAuthen
import org.keycloak.authentication.authenticators.client.JWTClientAuthenticator;
import org.keycloak.representations.idm.ClientPoliciesRepresentation;
import org.keycloak.representations.idm.ClientProfilesRepresentation;
import org.keycloak.representations.idm.ClientPolicyConditionConfigurationRepresentation;
import org.keycloak.services.clientpolicy.condition.ClientAccessTypeConditionFactory;
import org.keycloak.services.clientpolicy.executor.HolderOfKeyEnforcerExecutorFactory;
import org.keycloak.services.clientpolicy.executor.SecureClientAuthenticatorExecutorFactory;
@ -316,15 +317,17 @@ public class ClientPoliciesTest extends AbstractRealmTest {
assertAlertSuccess();
// assert JSON
ClientPolicyConditionConfigurationRepresentation conditionConfig =
createClientAccessTypeConditionConfig(Arrays.asList(ClientAccessTypeConditionFactory.TYPE_CONFIDENTIAL, ClientAccessTypeConditionFactory.TYPE_BEARERONLY, ClientAccessTypeConditionFactory.TYPE_PUBLIC));
conditionConfig.setNegativeLogic(Boolean.FALSE);
ClientPoliciesRepresentation expected = new ClientPoliciesBuilder()
.addPolicy(new ClientPolicyBuilder()
.createPolicy(policyName, policyDesc, true)
.addCondition(ClientAccessTypeConditionFactory.PROVIDER_ID,
createClientAccessTypeConditionConfig(Arrays.asList(ClientAccessTypeConditionFactory.TYPE_CONFIDENTIAL, ClientAccessTypeConditionFactory.TYPE_BEARERONLY, ClientAccessTypeConditionFactory.TYPE_PUBLIC)))
.addCondition(ClientAccessTypeConditionFactory.PROVIDER_ID, conditionConfig)
.addProfile(profileName)
.toRepresentation())
.toRepresentation();
assertClientPolicy(expected);
// remove condition