From 861e44b9c85ccc0cbcfc284f15569d81e85c3e5e Mon Sep 17 00:00:00 2001 From: Vaclav Muzikar Date: Thu, 7 Apr 2016 18:01:18 +0200 Subject: [PATCH] KEYCLOAK-2772 Add deletion test to GroupTest --- .../testsuite/admin/group/GroupTest.java | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java index c27b3368eb..adba8de095 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.net.URI; import java.util.LinkedList; import java.util.List; +import java.util.Set; /** @@ -189,19 +190,6 @@ public class GroupTest extends AbstractGroupTest { Assert.assertEquals(1, level3Group.getRealmRoles().size()); Assert.assertTrue(level3Group.getRealmRoles().contains("level3Role")); - try { - GroupRepresentation notFound = realm.getGroupByPath("/notFound"); - Assert.fail(); - } catch (NotFoundException e) { - - } - try { - GroupRepresentation notFound = realm.getGroupByPath("/top/notFound"); - Assert.fail(); - } catch (NotFoundException e) { - - } - UserRepresentation user = realm.users().search("direct-login", -1, -1).get(0); realm.users().get(user.getId()).joinGroup(level3Group.getId()); List membership = realm.users().get(user.getId()).groups(); @@ -232,5 +220,27 @@ public class GroupTest extends AbstractGroupTest { realm.removeDefaultGroup(level3Group.getId()); defaultGroups = realm.getDefaultGroups(); Assert.assertEquals(0, defaultGroups.size()); + + realm.groups().group(topGroup.getId()).remove(); + + try { + realm.getGroupByPath("/top/level2/level3"); + Assert.fail("Group should not have been found"); + } + catch (NotFoundException e) {} + + try { + realm.getGroupByPath("/top/level2"); + Assert.fail("Group should not have been found"); + } + catch (NotFoundException e) {} + + try { + realm.getGroupByPath("/top"); + Assert.fail("Group should not have been found"); + } + catch (NotFoundException e) {} + + Assert.assertNull(login("direct-login", "resource-owner", "secret", user.getId()).getRealmAccess()); } }