From be7775a9bee8debe35be6d1b2cf2df2838d6ca5a Mon Sep 17 00:00:00 2001 From: Pavel Drozd Date: Mon, 4 Mar 2024 15:07:38 +0100 Subject: [PATCH] LDAPSyncTest - additional removal of users at the end of the test Necessary when running with external AD Closes #27499 Signed-off-by: Pavel Drozd --- .../testsuite/federation/ldap/LDAPSyncTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPSyncTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPSyncTest.java index 7fe72abaf8..2b4198a1a8 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPSyncTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPSyncTest.java @@ -346,6 +346,16 @@ public class LDAPSyncTest extends AbstractLDAPTest { Assert.assertEquals("user1", user1.getFirstAttribute(LDAPConstants.LDAP_ID)); }); + // Remove all users from model - required step before the next test execution especially when running against external AD + testingClient.server().run(session -> { + LDAPTestContext ctx = LDAPTestContext.init(session); + // Remove all users from model + UserStoragePrivateUtil.userLocalStorage(session) + .searchForUserStream(ctx.getRealm(), Collections.emptyMap()) + .collect(Collectors.toList()) + .forEach(user -> UserStoragePrivateUtil.userLocalStorage(session).removeUser(ctx.getRealm(), user)); + }); + // Revert config changes ComponentRepresentation ldapRep = testRealm().components().component(ldapModelId).toRepresentation(); ldapRep.getConfig().putSingle(LDAPConstants.UUID_LDAP_ATTRIBUTE, origUuidAttrName);