Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ public Stream<UserRepresentation> getUsers(
attributes.put(UserModel.EMAIL_VERIFIED, emailVerified.toString());
}
addCreatedTimestampConditions(attributes, createdAfter, createdBefore);
attributes.putAll(searchAttributes);

return searchForUser(attributes, realm, userPermissionEvaluator, briefRepresentation, firstResult,
maxResults, false);
Expand Down Expand Up @@ -455,6 +456,7 @@ public Integer getUsersCount(
parameters.put(UserModel.EMAIL_VERIFIED, emailVerified.toString());
}
addCreatedTimestampConditions(parameters, createdAfter, createdBefore);
parameters.putAll(searchAttributes);
// search /users equivalent to this doesn't include service-accounts so counting shouldn't as well
parameters.put(UserModel.INCLUDE_SERVICE_ACCOUNT, "false");
if (userPermissionEvaluator.canView()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ public void searchByAttribute() {
assertEquals(0, users.size());
}

@Test
@DatabaseTest
public void searchUserWithQueryParameter() {
createUsers();

String query = mapToSearchQuery(Map.of("test", "test1"));
assertThat(managedRealm.admin().users().searchByAttributes(query), hasSize(1));
List<UserRepresentation> users = managedRealm.admin().users().search("username", null, null, null, null, null, null, query);
assertThat(users, hasSize(1));
assertThat(users.get(0).getUsername(), is("username1"));
assertThat(managedRealm.admin().users().count("username", null, null, null, null, null, null, query), is(1));
}

@Test
@DatabaseTest
public void searchByMultipleAttributes() {
Expand Down