KEYCLOAK-2704
User count missing in REST admin endpoint
This commit is contained in:
parent
cee8fee504
commit
48551d362a
3 changed files with 24 additions and 0 deletions
|
@ -29,6 +29,7 @@ import javax.ws.rs.QueryParam;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UsersResource {
|
||||
|
||||
|
@ -51,6 +52,11 @@ public interface UsersResource {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
Response create(UserRepresentation userRepresentation);
|
||||
|
||||
@Path("count")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
Map<String, Integer> count();
|
||||
|
||||
@Path("{id}")
|
||||
UserResource get(@PathParam("id") String id);
|
||||
|
||||
|
|
|
@ -681,6 +681,16 @@ public class UsersResource {
|
|||
return results;
|
||||
}
|
||||
|
||||
@Path("count")
|
||||
@GET
|
||||
@NoCache
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Integer> getUsersCount() {
|
||||
auth.requireView();
|
||||
|
||||
return Collections.singletonMap("count", session.users().getUsersCount(realm));
|
||||
}
|
||||
|
||||
@Path("{id}/role-mappings")
|
||||
public RoleMapperResource getRoleMappings(@PathParam("id") String id) {
|
||||
|
||||
|
|
|
@ -231,6 +231,14 @@ public class UserTest extends AbstractClientTest {
|
|||
assertEquals(9, users.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void count() {
|
||||
createUsers();
|
||||
|
||||
Integer count = realm.users().count().get("count");
|
||||
assertEquals(9, count.intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchPaginated() {
|
||||
createUsers();
|
||||
|
|
Loading…
Reference in a new issue