diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java index d3128b4424..4c713d21d5 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java @@ -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())); + }); + } }