Make sure pagination is used even when first is null for getGroups endpoint
Closes #25731 Signed-off-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
parent
b4d289c562
commit
e55ba5dcdc
2 changed files with 15 additions and 5 deletions
|
@ -100,13 +100,11 @@ public class GroupsResource {
|
|||
stream = ModelToRepresentation.searchGroupModelsByAttributes(session, realm, attributes, firstResult, maxResults);
|
||||
} else if (Objects.nonNull(search)) {
|
||||
stream = session.groups().searchForGroupByNameStream(realm, search.trim(), exact, firstResult, maxResults);
|
||||
} else if(Objects.nonNull(firstResult) && Objects.nonNull(maxResults)) {
|
||||
stream = session.groups().getTopLevelGroupsStream(realm, firstResult, maxResults);
|
||||
} else {
|
||||
stream = session.groups().getTopLevelGroupsStream(realm);
|
||||
stream = session.groups().getTopLevelGroupsStream(realm, firstResult, maxResults);
|
||||
}
|
||||
|
||||
if(populateHierarchy) {
|
||||
if (populateHierarchy) {
|
||||
return GroupUtils.populateGroupHierarchyFromSubGroups(session, realm, stream, !briefRepresentation, groupsEvaluator);
|
||||
}
|
||||
boolean canViewGlobal = groupsEvaluator.canView();
|
||||
|
|
|
@ -1149,9 +1149,21 @@ public class GroupTest extends AbstractGroupTest {
|
|||
List<GroupRepresentation> allGroups = realm.groups().groups();
|
||||
assertEquals(20, allGroups.size());
|
||||
|
||||
List<GroupRepresentation> slice = realm.groups().groups(5, 7);
|
||||
List<GroupRepresentation> slice = realm.groups().groups(0, 7);
|
||||
assertEquals(7, slice.size());
|
||||
|
||||
slice = realm.groups().groups(null, 7);
|
||||
assertEquals(7, slice.size());
|
||||
|
||||
slice = realm.groups().groups(10, null);
|
||||
assertEquals(10, slice.size());
|
||||
|
||||
slice = realm.groups().groups(5, 7);
|
||||
assertEquals(7, slice.size());
|
||||
|
||||
slice = realm.groups().groups(15, 7);
|
||||
assertEquals(5, slice.size());
|
||||
|
||||
List<GroupRepresentation> search = realm.groups().groups("group1",0,20);
|
||||
assertEquals(11, search.size());
|
||||
for(GroupRepresentation group : search) {
|
||||
|
|
Loading…
Reference in a new issue