KEYCLOAK-18380 Fix Groups search by name returns unwanted groups, cleanup test, skip tests on map storage provider feature

This commit is contained in:
Sebastian Rose 2021-06-09 11:14:06 +02:00 committed by Hynek Mlnařík
parent 17da3ee8d9
commit 565251d5a6

View file

@ -19,6 +19,7 @@ package org.keycloak.testsuite.admin.group;
import com.google.common.collect.Comparators;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.keycloak.admin.client.resource.GroupResource;
import org.keycloak.admin.client.resource.GroupsResource;
@ -26,6 +27,7 @@ import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RoleMappingResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.common.Profile;
import org.keycloak.events.admin.OperationType;
import org.keycloak.events.admin.ResourceType;
import org.keycloak.models.Constants;
@ -60,7 +62,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.ws.rs.ClientErrorException;
import javax.ws.rs.core.Response.Status;
import static org.hamcrest.Matchers.*;
@ -846,7 +847,9 @@ public class GroupTest extends AbstractGroupTest {
*/
@Test
public void searchForGroupsShouldOnlyReturnMatchingElementsOrIntermediatePaths() {
//Map Group Provider is not working the same way as JPA Group Provider
//see https://issues.redhat.com/browse/KEYCLOAK-18390
Assume.assumeTrue(Profile.getDisabledFeatures().contains(Profile.Feature.MAP_STORAGE));
/*
* /g1/g1.1-bubu
* /g1/g1.2-test1234
@ -876,8 +879,7 @@ public class GroupTest extends AbstractGroupTest {
try {
// we search for "test1234" and expect only /g1/g1.2-test1234, /g2-test1234 and /g3/g3.1-test1234 as a result
List<GroupRepresentation> result = realm.groups().groups(needle, 0, 100);
// ensure stable sorting to make tests pass
result = result.stream().sorted(Comparator.comparing(GroupRepresentation::getName)).collect(Collectors.toList());
assertEquals(3, result.size());
assertEquals("g1", result.get(0).getName());
assertEquals(1, result.get(0).getSubGroups().size());