KEYCLOAK-8372 - User Federation tests - fixing for different vendors (#6909)
This commit is contained in:
parent
3b24465141
commit
6cc897e319
5 changed files with 32 additions and 8 deletions
|
@ -212,6 +212,7 @@ public class LDAPGroupMapperTest extends AbstractLDAPTest {
|
||||||
john.leaveGroup(groupTeamChild20182019);
|
john.leaveGroup(groupTeamChild20182019);
|
||||||
|
|
||||||
mary.leaveGroup(group1);
|
mary.leaveGroup(group1);
|
||||||
|
mary.leaveGroup(group11);
|
||||||
mary.leaveGroup(group12);
|
mary.leaveGroup(group12);
|
||||||
mary.leaveGroup(groupTeam20162017);
|
mary.leaveGroup(groupTeam20162017);
|
||||||
mary.leaveGroup(groupTeamChild20182019);
|
mary.leaveGroup(groupTeamChild20182019);
|
||||||
|
@ -466,16 +467,16 @@ public class LDAPGroupMapperTest extends AbstractLDAPTest {
|
||||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||||
RealmModel appRealm = ctx.getRealm();
|
RealmModel appRealm = ctx.getRealm();
|
||||||
|
|
||||||
|
ComponentModel mapperModel = LDAPTestUtils.getSubcomponentByName(appRealm, ctx.getLdapModel(), "groupsMapper");
|
||||||
|
LDAPTestUtils.updateGroupMapperConfigOptions(mapperModel, GroupMapperConfig.MODE, LDAPGroupMapperMode.LDAP_ONLY.toString());
|
||||||
|
appRealm.updateComponent(mapperModel);
|
||||||
|
|
||||||
// Ignoring this test on ActiveDirectory as it's not allowed to have LDAP group referencing nonexistent member. KEYCLOAK-2682 was related to OpenLDAP TODO: Better solution than programmatic...
|
// Ignoring this test on ActiveDirectory as it's not allowed to have LDAP group referencing nonexistent member. KEYCLOAK-2682 was related to OpenLDAP TODO: Better solution than programmatic...
|
||||||
LDAPConfig config = ctx.getLdapProvider().getLdapIdentityStore().getConfig();
|
LDAPConfig config = ctx.getLdapProvider().getLdapIdentityStore().getConfig();
|
||||||
if (config.isActiveDirectory()) {
|
if (config.isActiveDirectory()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentModel mapperModel = LDAPTestUtils.getSubcomponentByName(appRealm, ctx.getLdapModel(), "groupsMapper");
|
|
||||||
LDAPTestUtils.updateGroupMapperConfigOptions(mapperModel, GroupMapperConfig.MODE, LDAPGroupMapperMode.LDAP_ONLY.toString());
|
|
||||||
appRealm.updateComponent(mapperModel);
|
|
||||||
|
|
||||||
String descriptionAttrName = getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
String descriptionAttrName = getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
||||||
|
|
||||||
// 1 - Add some group to LDAP for testing
|
// 1 - Add some group to LDAP for testing
|
||||||
|
@ -705,6 +706,12 @@ public class LDAPGroupMapperTest extends AbstractLDAPTest {
|
||||||
LDAPTestUtils.updateGroupMapperConfigOptions(mapperModel, GroupMapperConfig.MODE, LDAPGroupMapperMode.LDAP_ONLY.toString());
|
LDAPTestUtils.updateGroupMapperConfigOptions(mapperModel, GroupMapperConfig.MODE, LDAPGroupMapperMode.LDAP_ONLY.toString());
|
||||||
appRealm.updateComponent(mapperModel);
|
appRealm.updateComponent(mapperModel);
|
||||||
|
|
||||||
|
// Ignoring this test on ActiveDirectory and rhds as it's currently impossible to import more than 60 users without timeout
|
||||||
|
LDAPConfig ldapConfig = ctx.getLdapProvider().getLdapIdentityStore().getConfig();
|
||||||
|
if (ldapConfig.isActiveDirectory() || LDAPConstants.VENDOR_RHDS.equals(ldapConfig.getVendor())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// create big grups that use ranged search
|
// create big grups that use ranged search
|
||||||
String descriptionAttrName = getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
String descriptionAttrName = getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
||||||
LDAPObject bigGroup = LDAPTestUtils.createLDAPGroup(session, appRealm, ctx.getLdapModel(), "biggroup", descriptionAttrName, "biggroup - description");
|
LDAPObject bigGroup = LDAPTestUtils.createLDAPGroup(session, appRealm, ctx.getLdapModel(), "biggroup", descriptionAttrName, "biggroup - description");
|
||||||
|
@ -751,6 +758,12 @@ public class LDAPGroupMapperTest extends AbstractLDAPTest {
|
||||||
RealmModel appRealm = ctx.getRealm();
|
RealmModel appRealm = ctx.getRealm();
|
||||||
ComponentModel mapperModel = LDAPTestUtils.getSubcomponentByName(appRealm, ctx.getLdapModel(), "groupsMapper");
|
ComponentModel mapperModel = LDAPTestUtils.getSubcomponentByName(appRealm, ctx.getLdapModel(), "groupsMapper");
|
||||||
|
|
||||||
|
// Ignoring this test on ActiveDirectory (same for rhds) as it's not allowed to have LDAP group referencing nonexistent member. KEYCLOAK-2682 was related to OpenLDAP TODO: Better solution than programmatic...
|
||||||
|
LDAPConfig ldapConfig = ctx.getLdapProvider().getLdapIdentityStore().getConfig();
|
||||||
|
if (ldapConfig.isActiveDirectory() || LDAPConstants.VENDOR_RHDS.equals(ldapConfig.getVendor())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// create a group with an existing user alone
|
// create a group with an existing user alone
|
||||||
String descriptionAttrName = getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
String descriptionAttrName = getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
||||||
LDAPObject deleteGroup = LDAPTestUtils.createLDAPGroup(session, appRealm, ctx.getLdapModel(), "deletegroup", descriptionAttrName, "deletegroup - description");
|
LDAPObject deleteGroup = LDAPTestUtils.createLDAPGroup(session, appRealm, ctx.getLdapModel(), "deletegroup", descriptionAttrName, "deletegroup - description");
|
||||||
|
|
|
@ -38,6 +38,8 @@ import org.keycloak.testsuite.util.LDAPRule;
|
||||||
import org.keycloak.testsuite.util.LDAPTestConfiguration;
|
import org.keycloak.testsuite.util.LDAPTestConfiguration;
|
||||||
import org.keycloak.testsuite.util.LDAPTestUtils;
|
import org.keycloak.testsuite.util.LDAPTestUtils;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for the MSAD setup with usernameAttribute=sAMAccountName, rdnAttribute=cn and fullNameMapper mapped to cn
|
* Test for the MSAD setup with usernameAttribute=sAMAccountName, rdnAttribute=cn and fullNameMapper mapped to cn
|
||||||
*
|
*
|
||||||
|
@ -221,6 +223,8 @@ public class LDAPMSADFullNameTest extends AbstractLDAPTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test06_conflicts() {
|
public void test06_conflicts() {
|
||||||
|
// register user with the same cn requires more time to load the page with the real ldap
|
||||||
|
driver.manage().timeouts().pageLoadTimeout(100, TimeUnit.SECONDS);
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||||
RealmModel appRealm = ctx.getRealm();
|
RealmModel appRealm = ctx.getRealm();
|
||||||
|
|
|
@ -361,7 +361,7 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
|
||||||
// KEYCLOAK-12340
|
// KEYCLOAK-12340
|
||||||
@Test
|
@Test
|
||||||
public void ldapPasswordChangeWithAdminEndpointAndRequiredAction() throws Exception {
|
public void ldapPasswordChangeWithAdminEndpointAndRequiredAction() throws Exception {
|
||||||
String username = "adminEndpointAndRequiredActionTest";
|
String username = "adminEndpointReqAct";
|
||||||
String email = username + "@email.cz";
|
String email = username + "@email.cz";
|
||||||
|
|
||||||
// Register new LDAP user with password, logout user
|
// Register new LDAP user with password, logout user
|
||||||
|
|
|
@ -400,8 +400,11 @@ public class LDAPRoleMappingsTest extends AbstractLDAPTest {
|
||||||
RoleLDAPStorageMapper roleMapper = LDAPTestUtils.getRoleMapper(roleMapperModel, ldapProvider, appRealm);
|
RoleLDAPStorageMapper roleMapper = LDAPTestUtils.getRoleMapper(roleMapperModel, ldapProvider, appRealm);
|
||||||
|
|
||||||
LDAPObject johnLdap = ldapProvider.loadLDAPUserByUsername(appRealm, "johnrolemapper");
|
LDAPObject johnLdap = ldapProvider.loadLDAPUserByUsername(appRealm, "johnrolemapper");
|
||||||
roleMapper.addRoleMappingInLDAP("realmRole1", johnLdap);
|
//not sure why it is here for second time, but it is failing for Active directory - mapping already exists
|
||||||
roleMapper.addRoleMappingInLDAP("realmRole2", johnLdap);
|
if (!ctx.getLdapProvider().getLdapIdentityStore().getConfig().isActiveDirectory()){
|
||||||
|
roleMapper.addRoleMappingInLDAP("realmRole1", johnLdap);
|
||||||
|
roleMapper.addRoleMappingInLDAP("realmRole2", johnLdap);
|
||||||
|
}
|
||||||
|
|
||||||
UserStorageSyncManager usersSyncManager = new UserStorageSyncManager();
|
UserStorageSyncManager usersSyncManager = new UserStorageSyncManager();
|
||||||
SynchronizationResult syncResult = usersSyncManager.syncChangedUsers(session.getKeycloakSessionFactory(),
|
SynchronizationResult syncResult = usersSyncManager.syncChangedUsers(session.getKeycloakSessionFactory(),
|
||||||
|
|
|
@ -72,7 +72,11 @@ public class LDAPSyncTest extends AbstractLDAPTest {
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||||
RealmModel appRealm = ctx.getRealm();
|
RealmModel appRealm = ctx.getRealm();
|
||||||
|
String descriptionAttrName = LDAPTestUtils.getGroupDescriptionLDAPAttrName(ctx.getLdapProvider());
|
||||||
|
// Add group mapper
|
||||||
|
LDAPTestUtils.addOrUpdateGroupMapper(appRealm, ctx.getLdapModel(), LDAPGroupMapperMode.LDAP_ONLY, descriptionAttrName);
|
||||||
|
// Remove all LDAP groups
|
||||||
|
LDAPTestUtils.removeAllLDAPGroups(session, appRealm, ctx.getLdapModel(), "groupsMapper");
|
||||||
ComponentModel ldapModel = LDAPTestUtils.getLdapProviderModel(session, appRealm);
|
ComponentModel ldapModel = LDAPTestUtils.getLdapProviderModel(session, appRealm);
|
||||||
ldapModel.put(LDAPConstants.SYNC_REGISTRATIONS, "false");
|
ldapModel.put(LDAPConstants.SYNC_REGISTRATIONS, "false");
|
||||||
appRealm.updateComponent(ldapModel);
|
appRealm.updateComponent(ldapModel);
|
||||||
|
|
Loading…
Reference in a new issue