Skip to content

Commit f3b87f9

Browse files
committed
Skip testDotInUsername for the MSAD configuration with sAMAccountName as username
1 parent d2ea45e commit f3b87f9

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

testsuite/integration/src/test/java/org/keycloak/testsuite/federation/FederationProvidersIntegrationTest.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.junit.rules.TestRule;
1010
import org.junit.runners.MethodSorters;
1111
import org.keycloak.OAuth2Constants;
12+
import org.keycloak.federation.ldap.LDAPConfig;
1213
import org.keycloak.federation.ldap.LDAPFederationProvider;
1314
import org.keycloak.federation.ldap.LDAPFederationProviderFactory;
1415
import org.keycloak.federation.ldap.idm.model.LDAPObject;
@@ -353,20 +354,31 @@ public void testCaseSensitiveAttributeName() {
353354

354355
@Test
355356
public void testDotInUsername() {
356-
// Add LDAP user with same email like existing model user
357-
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
357+
KeycloakSession session = keycloakRule.startSession();
358+
boolean skip = false;
358359

359-
@Override
360-
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
361-
LDAPFederationProvider ldapFedProvider = FederationTestUtils.getLdapProvider(session, ldapModel);
360+
try {
361+
RealmModel appRealm = new RealmManager(session).getRealmByName("test");
362+
LDAPFederationProvider ldapFedProvider = FederationTestUtils.getLdapProvider(session, ldapModel);
363+
364+
// Workaround as dot is not allowed in sAMAccountName on active directory. So we will skip the test for this configuration
365+
LDAPConfig config = ldapFedProvider.getLdapIdentityStore().getConfig();
366+
if (config.isActiveDirectory() && config.getUsernameLdapAttribute().equals(LDAPConstants.SAM_ACCOUNT_NAME)) {
367+
skip = true;
368+
}
369+
370+
if (!skip) {
362371
LDAPObject johnDot = FederationTestUtils.addLDAPUser(ldapFedProvider, appRealm, "john,dot", "John", "Dot", "[email protected]", null, "12387");
363372
ldapFedProvider.getLdapIdentityStore().updatePassword(johnDot, "Password1");
364373
}
374+
} finally {
375+
keycloakRule.stopSession(session, false);
376+
}
365377

366-
});
367-
368-
// Try to import the duplicated LDAP user into Keycloak
369-
loginSuccessAndLogout("john,dot", "Password1");
378+
if (!skip) {
379+
// Try to import the user with dot in username into Keycloak
380+
loginSuccessAndLogout("john,dot", "Password1");
381+
}
370382
}
371383

372384
@Test

0 commit comments

Comments
 (0)