Skip to content

Commit

Permalink
LDAPSyncTest - additional removal of users at the end of the test
Browse files Browse the repository at this point in the history
Necessary when running with external AD

Closes keycloak#27499

Signed-off-by: Pavel Drozd <[email protected]>
(cherry picked from commit be7775a)
  • Loading branch information
pdrozd authored and miquelsi committed Jul 25, 2024
1 parent 3f8c12b commit 348c3c1
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@ public void test04SameUUIDAndUsernameSync() {
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);
Expand Down

0 comments on commit 348c3c1

Please sign in to comment.