diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java index 0af4d93045..d01dc7f610 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserModelTest.java @@ -9,6 +9,9 @@ import org.keycloak.models.UserModel; import org.keycloak.models.UserModel.RequiredAction; import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Stian Thorgersen @@ -35,6 +38,25 @@ public class UserModelTest extends AbstractModelTest { searchRealm = realmManager.getRealm(realm.getId()); UserModel persisted2 = session.users().getUserById(user.getId(), searchRealm); assertEquals(user, persisted2); + + Map attributes = new HashMap(); + attributes.put(UserModel.LAST_NAME, "last-name"); + List search = session.users().searchForUserByAttributes(attributes, realm); + Assert.assertEquals(search.size(), 1); + Assert.assertEquals(search.get(0).getUsername(), "user"); + + attributes.clear(); + attributes.put(UserModel.EMAIL, "email"); + search = session.users().searchForUserByAttributes(attributes, realm); + Assert.assertEquals(search.size(), 1); + Assert.assertEquals(search.get(0).getUsername(), "user"); + + attributes.clear(); + attributes.put(UserModel.LAST_NAME, "last-name"); + attributes.put(UserModel.EMAIL, "email"); + search = session.users().searchForUserByAttributes(attributes, realm); + Assert.assertEquals(search.size(), 1); + Assert.assertEquals(search.get(0).getUsername(), "user"); } @Test