Fixing tests

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This commit is contained in:
Alexander Schwartz
2025-10-24 16:45:35 +02:00
committed by Pedro Igor
parent 76f2e85b1e
commit 5995815bcc

View File

@@ -62,11 +62,13 @@ public abstract class AbstractAttributeToRoleMapper extends AbstractIdentityProv
if (!context.hasMapperGrantedRole(roleName)) {
if (this.applies(mapperModel, context)) {
context.addMapperGrantedRole(roleName);
if (user.getRealmRoleMappingsStream().noneMatch(r -> r.equals(role))) {
if ((!role.isClientRole() && user.getRealmRoleMappingsStream().noneMatch(r -> r.equals(role)))
|| (role.isClientRole() && user.getClientRoleMappingsStream(session.clients().getClientById(realm, role.getContainerId())).noneMatch(r -> r.equals(role)))) {
user.grantRole(role);
}
} else {
if (user.getRealmRoleMappingsStream().anyMatch(r -> r.equals(role))) {
if ((!role.isClientRole() && user.getRealmRoleMappingsStream().anyMatch(r -> r.equals(role)))
|| (role.isClientRole() && user.getClientRoleMappingsStream(session.clients().getClientById(realm, role.getContainerId())).anyMatch(r -> r.equals(role)))) {
user.deleteRoleMapping(role);
}
}