Skip testDotInUsername for the MSAD configuration with sAMAccountName as username

This commit is contained in:
mposolda 2015-07-24 13:01:39 +02:00
parent d2ea45e1eb
commit f3b87f9cf9

View file

@ -9,6 +9,7 @@ import org.junit.rules.RuleChain;
import org.junit.rules.TestRule; import org.junit.rules.TestRule;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.keycloak.OAuth2Constants; import org.keycloak.OAuth2Constants;
import org.keycloak.federation.ldap.LDAPConfig;
import org.keycloak.federation.ldap.LDAPFederationProvider; import org.keycloak.federation.ldap.LDAPFederationProvider;
import org.keycloak.federation.ldap.LDAPFederationProviderFactory; import org.keycloak.federation.ldap.LDAPFederationProviderFactory;
import org.keycloak.federation.ldap.idm.model.LDAPObject; import org.keycloak.federation.ldap.idm.model.LDAPObject;
@ -353,20 +354,31 @@ public class FederationProvidersIntegrationTest {
@Test @Test
public void testDotInUsername() { public void testDotInUsername() {
// Add LDAP user with same email like existing model user KeycloakSession session = keycloakRule.startSession();
keycloakRule.update(new KeycloakRule.KeycloakSetup() { boolean skip = false;
@Override try {
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) { RealmModel appRealm = new RealmManager(session).getRealmByName("test");
LDAPFederationProvider ldapFedProvider = FederationTestUtils.getLdapProvider(session, ldapModel); LDAPFederationProvider ldapFedProvider = FederationTestUtils.getLdapProvider(session, ldapModel);
// Workaround as dot is not allowed in sAMAccountName on active directory. So we will skip the test for this configuration
LDAPConfig config = ldapFedProvider.getLdapIdentityStore().getConfig();
if (config.isActiveDirectory() && config.getUsernameLdapAttribute().equals(LDAPConstants.SAM_ACCOUNT_NAME)) {
skip = true;
}
if (!skip) {
LDAPObject johnDot = FederationTestUtils.addLDAPUser(ldapFedProvider, appRealm, "john,dot", "John", "Dot", "johndot@email.org", null, "12387"); LDAPObject johnDot = FederationTestUtils.addLDAPUser(ldapFedProvider, appRealm, "john,dot", "John", "Dot", "johndot@email.org", null, "12387");
ldapFedProvider.getLdapIdentityStore().updatePassword(johnDot, "Password1"); ldapFedProvider.getLdapIdentityStore().updatePassword(johnDot, "Password1");
} }
} finally {
keycloakRule.stopSession(session, false);
}
}); if (!skip) {
// Try to import the user with dot in username into Keycloak
// Try to import the duplicated LDAP user into Keycloak loginSuccessAndLogout("john,dot", "Password1");
loginSuccessAndLogout("john,dot", "Password1"); }
} }
@Test @Test