From e52811ac28688cf47a313bbb20e34100a966f8bb Mon Sep 17 00:00:00 2001 From: mposolda Date: Mon, 1 Sep 2014 16:58:22 +0200 Subject: [PATCH] Added more props to LDAPEmbeddedServer to allow automated test with ActiveDirectory --- .../testutils/LDAPEmbeddedServer.java | 24 +++++++++++++++++++ .../FederationProvidersIntegrationTest.java | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/testsuite/integration/src/main/java/org/keycloak/testutils/LDAPEmbeddedServer.java b/testsuite/integration/src/main/java/org/keycloak/testutils/LDAPEmbeddedServer.java index 1c10b2429c..bbf932c3da 100755 --- a/testsuite/integration/src/main/java/org/keycloak/testutils/LDAPEmbeddedServer.java +++ b/testsuite/integration/src/main/java/org/keycloak/testutils/LDAPEmbeddedServer.java @@ -43,6 +43,9 @@ public class LDAPEmbeddedServer extends AbstractLDAPTest { protected boolean connectionPooling = true; protected boolean pagination = true; protected int batchSizeForSync = LDAPConstants.DEFAULT_BATCH_SIZE_FOR_SYNC; + protected String usernameLDAPAttribute; + protected String userObjectClasses; + protected boolean userAccountControlsAfterPasswordUpdate; public static String IDM_TEST_LDAP_CONNECTION_URL = "idm.test.ldap.connection.url"; public static String IDM_TEST_LDAP_BASE_DN = "idm.test.ldap.base.dn"; @@ -57,6 +60,9 @@ public class LDAPEmbeddedServer extends AbstractLDAPTest { public static String IDM_TEST_LDAP_CONNECTION_POOLING = "idm.test.ldap.connection.pooling"; public static String IDM_TEST_LDAP_PAGINATION = "idm.test.ldap.pagination"; public static String IDM_TEST_LDAP_BATCH_SIZE_FOR_SYNC = "idm.test.ldap.batch.size.for.sync"; + public static String IDM_TEST_LDAP_USERNAME_LDAP_ATTRIBUTE = "idm.test.ldap.username.ldap.attribute"; + public static String IDM_TEST_LDAP_USER_OBJECT_CLASSES = "idm.test.ldap.user.object.classes"; + public static String IDM_TEST_LDAP_USER_ACCOUNT_CONTROLS_AFTER_PASSWORD_UPDATE = "idm.test.ldap.user.account.controls.after.password.update"; public LDAPEmbeddedServer() { @@ -87,6 +93,9 @@ public class LDAPEmbeddedServer extends AbstractLDAPTest { connectionPooling = Boolean.parseBoolean(p.getProperty(IDM_TEST_LDAP_CONNECTION_POOLING, "true")); pagination = Boolean.parseBoolean(p.getProperty(IDM_TEST_LDAP_PAGINATION, "true")); batchSizeForSync = Integer.parseInt(p.getProperty(IDM_TEST_LDAP_BATCH_SIZE_FOR_SYNC, String.valueOf(batchSizeForSync))); + usernameLDAPAttribute = p.getProperty(IDM_TEST_LDAP_USERNAME_LDAP_ATTRIBUTE); + userObjectClasses = p.getProperty(IDM_TEST_LDAP_USER_OBJECT_CLASSES); + userAccountControlsAfterPasswordUpdate = Boolean.parseBoolean(p.getProperty(IDM_TEST_LDAP_USER_ACCOUNT_CONTROLS_AFTER_PASSWORD_UPDATE)); } @Override @@ -138,6 +147,9 @@ public class LDAPEmbeddedServer extends AbstractLDAPTest { ldapConfig.put(LDAPConstants.CONNECTION_POOLING, String.valueOf(isConnectionPooling())); ldapConfig.put(LDAPConstants.PAGINATION, String.valueOf(isPagination())); ldapConfig.put(LDAPConstants.BATCH_SIZE_FOR_SYNC, String.valueOf(getBatchSizeForSync())); + ldapConfig.put(LDAPConstants.USERNAME_LDAP_ATTRIBUTE, getUsernameLDAPAttribute()); + ldapConfig.put(LDAPConstants.USER_OBJECT_CLASSES, getUserObjectClasses()); + ldapConfig.put(LDAPConstants.USER_ACCOUNT_CONTROLS_AFTER_PASSWORD_UPDATE, String.valueOf(isUserAccountControlsAfterPasswordUpdate())); return ldapConfig; } @@ -224,6 +236,18 @@ public class LDAPEmbeddedServer extends AbstractLDAPTest { return batchSizeForSync; } + public String getUsernameLDAPAttribute() { + return usernameLDAPAttribute; + } + + public String getUserObjectClasses() { + return userObjectClasses; + } + + public boolean isUserAccountControlsAfterPasswordUpdate() { + return userAccountControlsAfterPasswordUpdate; + } + @Override public void importLDIF(String fileName) throws Exception { // import LDIF only in case we are running against embedded LDAP server diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java index 868092bbba..0ffa2ac6d0 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java @@ -195,7 +195,7 @@ public class FederationProvidersIntegrationTest { changePasswordPage.logout(); loginPage.open(); - loginPage.login("johnkeycloak", "password"); + loginPage.login("johnkeycloak", "bad-password"); Assert.assertEquals("Invalid username or password.", loginPage.getError()); loginPage.open();