Merge pull request #3669 from vmuzikar/KEYCLOAK-3959

KEYCLOAK-3959 Fix User Federation Console UI Tests
This commit is contained in:
Stian Thorgersen 2016-12-19 15:32:28 +01:00 committed by GitHub
commit d1a528eb07
6 changed files with 52 additions and 51 deletions

View file

@ -13,7 +13,7 @@ public class CreateKerberosUserProvider extends AdminConsoleCreate {
private KerberosUserProviderForm form; private KerberosUserProviderForm form;
public CreateKerberosUserProvider() { public CreateKerberosUserProvider() {
setEntity("user-federation"); setEntity("user-storage");
} }
@Override @Override

View file

@ -13,7 +13,7 @@ public class CreateLdapUserProvider extends AdminConsoleCreate {
private LdapUserProviderForm form; private LdapUserProviderForm form;
public CreateLdapUserProvider() { public CreateLdapUserProvider() {
setEntity("user-federation"); setEntity("user-storage");
} }
@Override @Override

View file

@ -54,7 +54,6 @@ public class KerberosUserProviderForm extends Form {
} }
public void setKerberosRealmInput(String kerberosRealm) { public void setKerberosRealmInput(String kerberosRealm) {
waitUntilElement(By.id("kerberosRealm")).is().present();
setInputValue(kerberosRealmInput, kerberosRealm); setInputValue(kerberosRealmInput, kerberosRealm);
} }
@ -75,7 +74,6 @@ public class KerberosUserProviderForm extends Form {
} }
public void selectEditMode(String mode) { public void selectEditMode(String mode) {
waitUntilElement(By.id("editMode")).is().present();
editModeSelect.selectByVisibleText(mode); editModeSelect.selectByVisibleText(mode);
} }

View file

@ -107,12 +107,12 @@ public abstract class AbstractConsoleTest extends AbstractAuthTest {
} }
public void assertAlertSuccess() { public void assertAlertSuccess() {
assertTrue(alert.isSuccess()); assertTrue("Alert is not success", alert.isSuccess());
alert.close(); alert.close();
} }
public void assertAlertDanger() { public void assertAlertDanger() {
assertTrue(alert.isDanger()); assertTrue("Alert is not danger", alert.isDanger());
alert.close(); alert.close();
} }

View file

@ -2,6 +2,7 @@ package org.keycloak.testsuite.console.federation;
import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.junit.Test; import org.junit.Test;
import org.keycloak.representations.idm.ComponentRepresentation;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserFederationProviderRepresentation; import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.testsuite.console.AbstractConsoleTest; import org.keycloak.testsuite.console.AbstractConsoleTest;
@ -34,8 +35,9 @@ public class KerberosUserFederationTest extends AbstractConsoleTest {
createKerberosUserProvider.form().setUpdateProfileFirstLogin(true); createKerberosUserProvider.form().setUpdateProfileFirstLogin(true);
createKerberosUserProvider.form().save(); createKerberosUserProvider.form().save();
assertAlertSuccess(); assertAlertSuccess();
RealmRepresentation realm = testRealmResource().toRepresentation();
UserFederationProviderRepresentation ufpr = realm.getUserFederationProviders().get(0); ComponentRepresentation ufpr = testRealmResource().components()
.query(null, "org.keycloak.storage.UserStorageProvider").get(0);
assertKerberosSetings(ufpr, "KEYCLOAK.ORG", "HTTP/localhost@KEYCLOAK.ORG", "http.keytab", "true", "true", "true"); assertKerberosSetings(ufpr, "KEYCLOAK.ORG", "HTTP/localhost@KEYCLOAK.ORG", "http.keytab", "true", "true", "true");
} }
@ -64,12 +66,12 @@ public class KerberosUserFederationTest extends AbstractConsoleTest {
assertAlertSuccess(); assertAlertSuccess();
} }
private void assertKerberosSetings(UserFederationProviderRepresentation ufpr, String kerberosRealm, String serverPrincipal, String keyTab, String debug, String useKerberosForPasswordAuthentication, String updateProfileFirstLogin) { private void assertKerberosSetings(ComponentRepresentation ufpr, String kerberosRealm, String serverPrincipal, String keyTab, String debug, String useKerberosForPasswordAuthentication, String updateProfileFirstLogin) {
assertEquals(kerberosRealm, ufpr.getConfig().get("kerberosRealm")); assertEquals(kerberosRealm, ufpr.getConfig().get("kerberosRealm").get(0));
assertEquals(serverPrincipal, ufpr.getConfig().get("serverPrincipal")); assertEquals(serverPrincipal, ufpr.getConfig().get("serverPrincipal").get(0));
assertEquals(keyTab, ufpr.getConfig().get("keyTab")); assertEquals(keyTab, ufpr.getConfig().get("keyTab").get(0));
assertEquals(debug, ufpr.getConfig().get("debug")); assertEquals(debug, ufpr.getConfig().get("debug").get(0));
assertEquals(useKerberosForPasswordAuthentication, ufpr.getConfig().get("allowKerberosAuthentication")); assertEquals(useKerberosForPasswordAuthentication, ufpr.getConfig().get("allowPasswordAuthentication").get(0));
assertEquals(updateProfileFirstLogin, ufpr.getConfig().get("updateProfileFirstLogin")); assertEquals(updateProfileFirstLogin, ufpr.getConfig().get("updateProfileFirstLogin").get(0));
} }
} }

View file

@ -3,8 +3,7 @@ package org.keycloak.testsuite.console.federation;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.junit.Test; import org.junit.Test;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.ComponentRepresentation;
import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.testsuite.console.AbstractConsoleTest; import org.keycloak.testsuite.console.AbstractConsoleTest;
import org.keycloak.testsuite.console.page.federation.CreateLdapUserProvider; import org.keycloak.testsuite.console.page.federation.CreateLdapUserProvider;
import org.keycloak.util.ldap.LDAPEmbeddedServer; import org.keycloak.util.ldap.LDAPEmbeddedServer;
@ -53,12 +52,13 @@ public class LdapUserFederationTest extends AbstractConsoleTest {
createLdapUserProvider.form().save(); createLdapUserProvider.form().save();
assertAlertSuccess(); assertAlertSuccess();
RealmRepresentation realm = testRealmResource().toRepresentation(); ComponentRepresentation ufpr = testRealmResource().components()
UserFederationProviderRepresentation ufpr = realm.getUserFederationProviders().get(0); .query(null, "org.keycloak.storage.UserStorageProvider").get(0);
assertLdapProviderSetting(ufpr, "ldap", 0, WRITABLE, "false", "ad", "1", "true", "true", "false");
assertLdapProviderSetting(ufpr, "ldap", "0", WRITABLE, "false", "ad", "1", "true", "true", "false");
assertLdapBasicMapping(ufpr, "cn", "cn", "objectGUID", "person, organizationalPerson, user", assertLdapBasicMapping(ufpr, "cn", "cn", "objectGUID", "person, organizationalPerson, user",
"ou=People,dc=keycloak,dc=org"); "ou=People,dc=keycloak,dc=org");
assertLdapSyncSetings(ufpr, "1000", 0, 0); assertLdapSyncSetings(ufpr, "1000", "-1", "-1");
assertLdapKerberosSetings(ufpr, "KEYCLOAK.ORG", "HTTP/localhost@KEYCLOAK.ORG", "http.keytab", "true", "false"); assertLdapKerberosSetings(ufpr, "KEYCLOAK.ORG", "HTTP/localhost@KEYCLOAK.ORG", "http.keytab", "true", "false");
} }
@ -75,12 +75,13 @@ public class LdapUserFederationTest extends AbstractConsoleTest {
createLdapUserProvider.form().save(); createLdapUserProvider.form().save();
assertAlertSuccess(); assertAlertSuccess();
RealmRepresentation realm = testRealmResource().toRepresentation(); ComponentRepresentation ufpr = testRealmResource().components()
UserFederationProviderRepresentation ufpr = realm.getUserFederationProviders().get(0); .query(null, "org.keycloak.storage.UserStorageProvider").get(0);
assertLdapProviderSetting(ufpr, "ldap", 0, READ_ONLY, "false", "rhds", "1", "true", "true", "true");
assertLdapProviderSetting(ufpr, "ldap", "0", READ_ONLY, "false", "rhds", "1", "true", "true", "true");
assertLdapBasicMapping(ufpr, "uid", "uid", "nsuniqueid", "inetOrgPerson, organizationalPerson", assertLdapBasicMapping(ufpr, "uid", "uid", "nsuniqueid", "inetOrgPerson, organizationalPerson",
"ou=People,dc=keycloak,dc=org"); "ou=People,dc=keycloak,dc=org");
assertLdapSyncSetings(ufpr, "1000", 0, 0); assertLdapSyncSetings(ufpr, "1000", "-1", "-1");
} }
@Test @Test
@ -175,44 +176,44 @@ public class LdapUserFederationTest extends AbstractConsoleTest {
assertTrue("Vendors list doesn't match", vendorsExpected.containsAll(vendorsActual)); assertTrue("Vendors list doesn't match", vendorsExpected.containsAll(vendorsActual));
} }
private void assertLdapProviderSetting(UserFederationProviderRepresentation ufpr, String name, int priority, private void assertLdapProviderSetting(ComponentRepresentation ufpr, String name, String priority,
String editMode, String syncRegistrations, String vendor, String searchScope, String connectionPooling, String editMode, String syncRegistrations, String vendor, String searchScope, String connectionPooling,
String pagination, String enableAccountAfterPasswordUpdate) { String pagination, String enableAccountAfterPasswordUpdate) {
assertEquals(name, ufpr.getDisplayName()); assertEquals(name, ufpr.getName());
assertEquals(priority, ufpr.getPriority()); assertEquals(priority, ufpr.getConfig().get("priority").get(0));
assertEquals(editMode, ufpr.getConfig().get("editMode")); assertEquals(editMode, ufpr.getConfig().get("editMode").get(0));
assertEquals(syncRegistrations, ufpr.getConfig().get("syncRegistrations")); assertEquals(syncRegistrations, ufpr.getConfig().get("syncRegistrations").get(0));
assertEquals(vendor, ufpr.getConfig().get("vendor")); assertEquals(vendor, ufpr.getConfig().get("vendor").get(0));
assertEquals(searchScope, ufpr.getConfig().get("searchScope")); assertEquals(searchScope, ufpr.getConfig().get("searchScope").get(0));
assertEquals(connectionPooling, ufpr.getConfig().get("connectionPooling")); assertEquals(connectionPooling, ufpr.getConfig().get("connectionPooling").get(0));
assertEquals(pagination, ufpr.getConfig().get("pagination")); assertEquals(pagination, ufpr.getConfig().get("pagination").get(0));
// assertEquals(enableAccountAfterPasswordUpdate, ufpr.getConfig().get("userAccountControlsAfterPasswordUpdate")); // assertEquals(enableAccountAfterPasswordUpdate, ufpr.getConfig().get("userAccountControlsAfterPasswordUpdate"));
} }
private void assertLdapBasicMapping(UserFederationProviderRepresentation ufpr, String usernameLdapAttribute, private void assertLdapBasicMapping(ComponentRepresentation ufpr, String usernameLdapAttribute,
String rdnLdapAttr, String uuidLdapAttr, String userObjectClasses, String userDN) { String rdnLdapAttr, String uuidLdapAttr, String userObjectClasses, String userDN) {
assertEquals(usernameLdapAttribute, ufpr.getConfig().get("usernameLDAPAttribute")); assertEquals(usernameLdapAttribute, ufpr.getConfig().get("usernameLDAPAttribute").get(0));
assertEquals(rdnLdapAttr, ufpr.getConfig().get("rdnLDAPAttribute")); assertEquals(rdnLdapAttr, ufpr.getConfig().get("rdnLDAPAttribute").get(0));
assertEquals(uuidLdapAttr, ufpr.getConfig().get("uuidLDAPAttribute")); assertEquals(uuidLdapAttr, ufpr.getConfig().get("uuidLDAPAttribute").get(0));
assertEquals(userObjectClasses, ufpr.getConfig().get("userObjectClasses")); assertEquals(userObjectClasses, ufpr.getConfig().get("userObjectClasses").get(0));
assertEquals(userDN, ufpr.getConfig().get("usersDn")); assertEquals(userDN, ufpr.getConfig().get("usersDn").get(0));
} }
private void assertLdapKerberosSetings(UserFederationProviderRepresentation ufpr, String kerberosRealm, private void assertLdapKerberosSetings(ComponentRepresentation ufpr, String kerberosRealm,
String serverPrincipal, String keyTab, String debug, String useKerberosForPasswordAuthentication) { String serverPrincipal, String keyTab, String debug, String useKerberosForPasswordAuthentication) {
assertEquals(kerberosRealm, ufpr.getConfig().get("kerberosRealm")); assertEquals(kerberosRealm, ufpr.getConfig().get("kerberosRealm").get(0));
assertEquals(serverPrincipal, ufpr.getConfig().get("serverPrincipal")); assertEquals(serverPrincipal, ufpr.getConfig().get("serverPrincipal").get(0));
assertEquals(keyTab, ufpr.getConfig().get("keyTab")); assertEquals(keyTab, ufpr.getConfig().get("keyTab").get(0));
assertEquals(debug, ufpr.getConfig().get("debug")); assertEquals(debug, ufpr.getConfig().get("debug").get(0));
assertEquals(useKerberosForPasswordAuthentication, assertEquals(useKerberosForPasswordAuthentication,
ufpr.getConfig().get("useKerberosForPasswordAuthentication")); ufpr.getConfig().get("useKerberosForPasswordAuthentication").get(0));
} }
private void assertLdapSyncSetings(UserFederationProviderRepresentation ufpr, String batchSize, private void assertLdapSyncSetings(ComponentRepresentation ufpr, String batchSize,
int periodicFullSync, int periodicChangedUsersSync) { String periodicFullSync, String periodicChangedUsersSync) {
assertEquals(batchSize, ufpr.getConfig().get("batchSizeForSync")); assertEquals(batchSize, ufpr.getConfig().get("batchSizeForSync").get(0));
assertEquals(periodicFullSync, ufpr.getFullSyncPeriod()); assertEquals(periodicFullSync, ufpr.getConfig().get("fullSyncPeriod").get(0));
assertEquals(periodicChangedUsersSync, ufpr.getChangedSyncPeriod()); assertEquals(periodicChangedUsersSync, ufpr.getConfig().get("changedSyncPeriod").get(0));
} }
private LDAPEmbeddedServer startEmbeddedLdapServer() throws Exception { private LDAPEmbeddedServer startEmbeddedLdapServer() throws Exception {