diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/storage/ldap/noimport/LDAPProvidersIntegrationNoImportTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/storage/ldap/noimport/LDAPProvidersIntegrationNoImportTest.java index 5aa1c94022..a2841d8e30 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/storage/ldap/noimport/LDAPProvidersIntegrationNoImportTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/storage/ldap/noimport/LDAPProvidersIntegrationNoImportTest.java @@ -211,6 +211,45 @@ public class LDAPProvidersIntegrationNoImportTest { oauth.openLogout(); } + + @Test + public void testLDAPUserImportOnCreationOrLogin() { + + KeycloakSession session = keycloakRule.startSession(); + RealmModel appRealm = new RealmManager(session).getRealmByName("test"); + LDAPStorageProvider ldapProvider = LDAPTestUtils.getLdapProvider(session, ldapModel); + LDAPConfig config = ldapProvider.getLdapIdentityStore().getConfig(); + + // Make sure mary is gone + LDAPTestUtils.removeLDAPUserByUsername(ldapProvider, appRealm, config, "maryjane"); + + + // Create the user in LDAP and register him + // + LDAPObject mary = LDAPTestUtils.addLDAPUser(ldapProvider, appRealm, "maryjane", "mary", "yram", "mj@testing.redhat.cz", null, "12398"); + LDAPTestUtils.updateLDAPPassword(ldapProvider, mary, "Password1"); + + try { + + // Log in and out of the user + loginSuccessAndLogout("maryjane", "Password1"); + + // Delete LDAP User + LDAPTestUtils.removeLDAPUserByUsername(ldapProvider, appRealm, config, "maryjane"); + + // Make sure the deletion took place. + List deletedUsers = session.users().searchForUser("mary yram", appRealm); + Assert.assertTrue(deletedUsers.isEmpty()); + + } finally { + keycloakRule.stopSession(session, false); + } + } + + + + + @Test public void caseInsensitiveSearch() { KeycloakSession session = keycloakRule.startSession();