Fix multi-valued LDAP attribute support
FullName LDAP storage mapper was delegating to single-valued setter even when multi-valued setter was called. Closes #22091 Signed-off-by: Tero Saarni <tero.saarni@est.tech>
This commit is contained in:
parent
cdb61215c9
commit
22d093f5c0
1 changed files with 32 additions and 0 deletions
|
@ -171,4 +171,36 @@ public class LDAPProvidersFullNameMapperTest extends AbstractLDAPTest {
|
|||
session.users().removeUser(appRealm, fullnameUser);
|
||||
});
|
||||
}
|
||||
|
||||
// Test for bug https://github.com/keycloak/keycloak/issues/22091
|
||||
@Test
|
||||
public void testMultiValuedAttributes() {
|
||||
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
RealmModel appRealm = ctx.getRealm();
|
||||
|
||||
ComponentModel ldapModel = LDAPTestUtils.getLdapProviderModel(appRealm);
|
||||
LDAPStorageProvider ldapFedProvider = LDAPTestUtils.getLdapProvider(session, ldapModel);
|
||||
LDAPTestUtils.addLDAPUser(ldapFedProvider, appRealm, "fullname", "James", "Dee", "fullname@email.org", null, "4578");
|
||||
});
|
||||
|
||||
// Add multi-attribute value to the user while fullname mapper is used.
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
RealmModel appRealm = ctx.getRealm();
|
||||
|
||||
UserModel fullnameUser = session.users().getUserByUsername(appRealm, "fullname");
|
||||
fullnameUser.setAttribute("roles", Arrays.asList("role1", "role2"));
|
||||
});
|
||||
|
||||
// Assert that multi-valued attribute is set.
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
RealmModel appRealm = ctx.getRealm();
|
||||
|
||||
UserModel fullnameUser = session.users().getUserByUsername(appRealm, "fullname");
|
||||
Assert.assertEquals(Arrays.asList("role1", "role2"), fullnameUser.getAttributeStream("roles").collect(Collectors.toList()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue