diff --git a/core/pom.xml b/core/pom.xml
index 9dccdb5a7a..b7e44fce6e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -45,9 +45,9 @@
- org.springframework
+ org.springframework.ldap
spring-ldap
- 1.1.2
+ 1.2-RC1
true
@@ -120,13 +120,19 @@
org.apache.directory.server
apacheds-core
- 1.0.0
+ 1.0.2
test
+ org.apache.directory.server
+ apacheds-server-jndi
+ 1.0.2
+ test
+
+
org.slf4j
slf4j-log4j12
- 1.0.1
+ 1.4.3
test
@@ -138,7 +144,8 @@
log4j
log4j
-
+ 1.2.14
+
diff --git a/core/src/main/java/org/acegisecurity/ldap/DefaultInitialDirContextFactory.java b/core/src/main/java/org/acegisecurity/ldap/DefaultInitialDirContextFactory.java
index 06f1c559da..8ca124a85f 100644
--- a/core/src/main/java/org/acegisecurity/ldap/DefaultInitialDirContextFactory.java
+++ b/core/src/main/java/org/acegisecurity/ldap/DefaultInitialDirContextFactory.java
@@ -26,9 +26,9 @@ import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.util.Assert;
-import org.springframework.ldap.ContextSource;
import org.springframework.ldap.UncategorizedLdapException;
-import org.springframework.ldap.support.DefaultDirObjectFactory;
+import org.springframework.ldap.core.ContextSource;
+import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.dao.DataAccessException;
import java.util.Hashtable;
diff --git a/core/src/main/java/org/acegisecurity/ldap/InitialDirContextFactory.java b/core/src/main/java/org/acegisecurity/ldap/InitialDirContextFactory.java
index bc2806d114..4a79af5513 100644
--- a/core/src/main/java/org/acegisecurity/ldap/InitialDirContextFactory.java
+++ b/core/src/main/java/org/acegisecurity/ldap/InitialDirContextFactory.java
@@ -15,7 +15,7 @@
package org.acegisecurity.ldap;
-import org.springframework.ldap.ContextSource;
+import org.springframework.ldap.core.ContextSource;
import javax.naming.directory.DirContext;
diff --git a/core/src/main/java/org/acegisecurity/ldap/LdapUtils.java b/core/src/main/java/org/acegisecurity/ldap/LdapUtils.java
index 631488355a..cb2d8c51e4 100644
--- a/core/src/main/java/org/acegisecurity/ldap/LdapUtils.java
+++ b/core/src/main/java/org/acegisecurity/ldap/LdapUtils.java
@@ -19,8 +19,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
-import org.springframework.ldap.support.DistinguishedName;
-import org.springframework.ldap.support.DirContextAdapter;
+import org.springframework.ldap.core.DirContextAdapter;
+import org.springframework.ldap.core.DistinguishedName;
import java.io.UnsupportedEncodingException;
diff --git a/core/src/main/java/org/acegisecurity/ldap/SpringSecurityLdapTemplate.java b/core/src/main/java/org/acegisecurity/ldap/SpringSecurityLdapTemplate.java
index 953b0a6549..b933ae64d5 100644
--- a/core/src/main/java/org/acegisecurity/ldap/SpringSecurityLdapTemplate.java
+++ b/core/src/main/java/org/acegisecurity/ldap/SpringSecurityLdapTemplate.java
@@ -20,11 +20,11 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
-import org.springframework.ldap.ContextSource;
-import org.springframework.ldap.ContextExecutor;
-import org.springframework.ldap.ContextMapper;
-import org.springframework.ldap.support.DirContextAdapter;
-import org.springframework.ldap.support.DistinguishedName;
+import org.springframework.ldap.core.ContextExecutor;
+import org.springframework.ldap.core.ContextSource;
+import org.springframework.ldap.core.DirContextAdapter;
+import org.springframework.ldap.core.ContextMapper;
+import org.springframework.ldap.core.DistinguishedName;
import java.util.HashSet;
import java.util.Set;
@@ -49,7 +49,7 @@ import javax.naming.directory.SearchResult;
* @author Ben Alex
* @author Luke Taylor
*/
-public class SpringSecurityLdapTemplate extends org.springframework.ldap.LdapTemplate {
+public class SpringSecurityLdapTemplate extends org.springframework.ldap.core.LdapTemplate {
//~ Static fields/initializers =====================================================================================
public static final String[] NO_ATTRS = new String[0];
diff --git a/core/src/main/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearch.java b/core/src/main/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearch.java
index a41353dee0..fc91e87d96 100644
--- a/core/src/main/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearch.java
+++ b/core/src/main/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearch.java
@@ -30,7 +30,8 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.util.Assert;
-import org.springframework.ldap.ContextSource;
+
+import org.springframework.ldap.core.ContextSource;
import javax.naming.directory.SearchControls;
diff --git a/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java b/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java
index 7f3a568c3e..8e1cf4e164 100644
--- a/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java
+++ b/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java
@@ -31,7 +31,7 @@ import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.util.Assert;
-import org.springframework.ldap.ContextMapper;
+import org.springframework.ldap.core.ContextMapper;
import java.text.MessageFormat;
diff --git a/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticator.java b/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticator.java
index 156bb86db4..4a9cdf393f 100644
--- a/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticator.java
+++ b/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticator.java
@@ -25,8 +25,8 @@ import org.acegisecurity.userdetails.ldap.LdapUserDetailsImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.ldap.ContextSource;
import org.springframework.dao.DataAccessException;
+import org.springframework.ldap.core.ContextSource;
import javax.naming.directory.DirContext;
import java.util.Iterator;
diff --git a/core/src/test/java/org/acegisecurity/ldap/AbstractLdapIntegrationTests.java b/core/src/test/java/org/acegisecurity/ldap/AbstractLdapIntegrationTests.java
new file mode 100644
index 0000000000..7c6f7b4312
--- /dev/null
+++ b/core/src/test/java/org/acegisecurity/ldap/AbstractLdapIntegrationTests.java
@@ -0,0 +1,75 @@
+/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.acegisecurity.ldap;
+
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+import org.springframework.ldap.core.ContextSource;
+import org.springframework.core.io.ClassPathResource;
+
+import java.io.File;
+
+/**
+ * Based on class borrowed from Spring Ldap project.
+ *
+ * @author Luke Taylor
+ * @version $Id$
+ */
+public abstract class AbstractLdapIntegrationTests extends AbstractDependencyInjectionSpringContextTests {
+ private LdapServerManager ldapServerManager;
+ private ContextSource contextSource;
+ private DefaultInitialDirContextFactory initialDirContextFactory;
+
+ protected AbstractLdapIntegrationTests() {
+ super.setAutowireMode(AUTOWIRE_BY_NAME);
+ }
+
+ protected String[] getConfigLocations() {
+ return new String[] {"/org/acegisecurity/ldap/ldapIntegrationTestContext.xml"};
+ }
+
+
+ protected void onSetUp() throws Exception {
+ super.onSetUp();
+
+ ClassPathResource ldifs = new ClassPathResource("org/acegisecurity/ldap/setup_data.ldif");
+
+ ldapServerManager.cleanAndSetup(ldifs.getFile().getAbsolutePath());
+ }
+
+ public void setLdapServerManager(LdapServerManager ldapServerManager) {
+ this.ldapServerManager = ldapServerManager;
+ }
+
+ public ContextSource getContextSource() {
+ return contextSource;
+ }
+
+ public void setContextSource(ContextSource contextSource) {
+ this.contextSource = contextSource;
+ }
+
+ /**
+ * We have both a context source and intitialdircontextfactory. The former is also used in
+ * the cleanAndSetup method so any mods during tests can mess it up.
+ * TODO: Once the initialdircontextfactory stuff has been refactored, revisit this and remove this property.
+ */
+ public DefaultInitialDirContextFactory getInitialDirContextFactory() {
+ return initialDirContextFactory;
+ }
+
+ public void setInitialDirContextFactory(DefaultInitialDirContextFactory initialDirContextFactory) {
+ this.initialDirContextFactory = initialDirContextFactory;
+ }
+}
diff --git a/core/src/test/java/org/acegisecurity/ldap/AbstractLdapServerTestCase.java b/core/src/test/java/org/acegisecurity/ldap/AbstractLdapServerTestCase.java
deleted file mode 100644
index 5f61bab1f2..0000000000
--- a/core/src/test/java/org/acegisecurity/ldap/AbstractLdapServerTestCase.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.acegisecurity.ldap;
-
-import junit.framework.TestCase;
-
-import org.apache.directory.server.core.jndi.CoreContextFactory;
-
-import java.util.Hashtable;
-
-
-/**
- * @author Luke Taylor
- * @version $Id$
- */
-public abstract class AbstractLdapServerTestCase extends TestCase {
- //~ Static fields/initializers =====================================================================================
-
- private static final String ROOT_DN = "dc=acegisecurity,dc=org";
- protected static final String MANAGER_USER = "cn=manager," + ROOT_DN;
- protected static final String MANAGER_PASSWORD = "acegisecurity";
-
- // External server config
-// private static final String PROVIDER_URL = "ldap://gorille:389/"+ROOT_DN;
-// private static final String CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
-// private static final Hashtable EXTRA_ENV = new Hashtable();
-
- // Embedded (non-networked) server config
- private static final LdapTestServer SERVER = new LdapTestServer();
- private static final String PROVIDER_URL = ROOT_DN;
- private static final String CONTEXT_FACTORY = CoreContextFactory.class.getName();
- private static final Hashtable EXTRA_ENV = SERVER.getConfiguration().toJndiEnvironment();
-
- //~ Instance fields ================================================================================================
-
- private DefaultInitialDirContextFactory idf;
-
- //~ Constructors ===================================================================================================
-
- protected AbstractLdapServerTestCase() {
- }
-
- protected AbstractLdapServerTestCase(String string) {
- super(string);
- }
-
- //~ Methods ========================================================================================================
-
- protected DefaultInitialDirContextFactory getInitialCtxFactory() {
- return idf;
- }
-
- protected void onSetUp() {
- }
-
- public final void setUp() {
- idf = new DefaultInitialDirContextFactory(PROVIDER_URL);
- idf.setInitialContextFactory(CONTEXT_FACTORY);
- idf.setExtraEnvVars(EXTRA_ENV);
- idf.setUseLdapContext(true);
-
- onSetUp();
- }
-}
diff --git a/core/src/test/java/org/acegisecurity/ldap/ConfigEnvHelper.java b/core/src/test/java/org/acegisecurity/ldap/ConfigEnvHelper.java
new file mode 100644
index 0000000000..e9bba25746
--- /dev/null
+++ b/core/src/test/java/org/acegisecurity/ldap/ConfigEnvHelper.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.acegisecurity.ldap;
+
+import java.io.File;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+
+import org.apache.directory.server.configuration.MutableServerStartupConfiguration;
+import org.apache.directory.server.jndi.ServerContextFactory;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Helper class to simplify Spring configuration of ApacheDS.
+ *
+ * @author Mattias Arthursson
+ * @author Luke Taylor (borrowed from Spring Ldap project).
+ */
+public class ConfigEnvHelper implements InitializingBean {
+ private final MutableServerStartupConfiguration configuration;
+
+ private final Hashtable initialEnv;
+
+ public ConfigEnvHelper(Hashtable initialEnv,
+ MutableServerStartupConfiguration configuration) {
+
+ this.initialEnv = initialEnv;
+ this.configuration = configuration;
+ }
+
+ public Hashtable getEnv() {
+ return initialEnv;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ // Attempt to use the maven target directory for the apache ds store. Property is passed
+ // through surefire plugin setup in pom.xml.
+
+ String apacheWorkDir = System.getProperty("apacheDSWorkDir");
+
+ if (apacheWorkDir == null) {
+ apacheWorkDir = System.getProperty("java.io.tmpdir") + File.separator + "apacheds-spring-security";
+ }
+
+ File workingDir = new File(apacheWorkDir);
+
+ initialEnv.put(Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName());
+ configuration.setWorkingDirectory(workingDir);
+ initialEnv.putAll(configuration.toJndiEnvironment());
+ }
+}
diff --git a/core/src/test/java/org/acegisecurity/ldap/DefaultInitialDirContextFactoryTests.java b/core/src/test/java/org/acegisecurity/ldap/DefaultInitialDirContextFactoryTests.java
index 07dbf0d0bd..cc87a4a9dd 100644
--- a/core/src/test/java/org/acegisecurity/ldap/DefaultInitialDirContextFactoryTests.java
+++ b/core/src/test/java/org/acegisecurity/ldap/DefaultInitialDirContextFactoryTests.java
@@ -18,7 +18,6 @@ package org.acegisecurity.ldap;
import org.acegisecurity.AcegiMessageSource;
import org.acegisecurity.BadCredentialsException;
import org.springframework.ldap.UncategorizedLdapException;
-import org.springframework.ldap.support.DirContextAdapter;
import java.util.Hashtable;
@@ -32,15 +31,16 @@ import javax.naming.directory.DirContext;
* @author Luke Taylor
* @version $Id$
*/
-public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTestCase {
+public class DefaultInitialDirContextFactoryTests extends AbstractLdapIntegrationTests {
//~ Instance fields ================================================================================================
DefaultInitialDirContextFactory idf;
//~ Methods ========================================================================================================
- public void onSetUp() {
- idf = getInitialCtxFactory();
+ public void onSetUp() throws Exception {
+ super.onSetUp();
+ idf = getInitialDirContextFactory();
idf.setMessageSource(new AcegiMessageSource());
}
@@ -65,9 +65,8 @@ public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTest
assertEquals("", idf.getRootDn());
}
- public void testBindAsManagerFailsIfNoPasswordSet()
- throws Exception {
- idf.setManagerDn(MANAGER_USER);
+ public void testBindAsManagerFailsIfNoPasswordSet() throws Exception {
+ idf.setManagerDn("uid=bob,ou=people,dc=acegisecurity,dc=org");
DirContext ctx = null;
@@ -83,8 +82,8 @@ public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTest
}
public void testBindAsManagerSucceeds() throws Exception {
- idf.setManagerPassword(MANAGER_PASSWORD);
- idf.setManagerDn(MANAGER_USER);
+ idf.setManagerPassword("bobspassword");
+ idf.setManagerDn("uid=bob,ou=people,dc=acegisecurity,dc=org");
DirContext ctx = idf.newInitialDirContext();
// Can't rely on this property being there with embedded server
@@ -92,8 +91,7 @@ public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTest
ctx.close();
}
- public void testConnectionAsSpecificUserSucceeds()
- throws Exception {
+ public void testConnectionAsSpecificUserSucceeds() throws Exception {
DirContext ctx = idf.newInitialDirContext("uid=Bob,ou=people,dc=acegisecurity,dc=org", "bobspassword");
// We don't want pooling for specific users.
// assertNull(ctx.getEnvironment().get("com.sun.jndi.ldap.connect.pool"));
@@ -148,7 +146,7 @@ public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTest
public void testInvalidPasswordCausesBadCredentialsException()
throws Exception {
- idf.setManagerDn(MANAGER_USER);
+ idf.setManagerDn("uid=bob,ou=people,dc=acegisecurity,dc=org");
idf.setManagerPassword("wrongpassword");
DirContext ctx = null;
diff --git a/core/src/test/java/org/acegisecurity/ldap/LdapServerManager.java b/core/src/test/java/org/acegisecurity/ldap/LdapServerManager.java
new file mode 100644
index 0000000000..d6d4b21633
--- /dev/null
+++ b/core/src/test/java/org/acegisecurity/ldap/LdapServerManager.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2005-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.acegisecurity.ldap;
+
+import java.util.Properties;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.ContextNotEmptyException;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NameNotFoundException;
+import javax.naming.directory.DirContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.directory.server.jndi.ServerContextFactory;
+import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
+
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.ldap.core.ContextSource;
+import org.springframework.ldap.core.DistinguishedName;
+import org.springframework.ldap.core.support.DefaultDirObjectFactory;
+
+
+/**
+ * Utility class to initialize the apache directory server for use in the integration tests.
+ *
+ * @author Mattias Arthursson
+ * @author Luke Taylor (borrowed from Spring Ldap project).
+ *
+ */
+public class LdapServerManager implements DisposableBean {
+ private static Log log = LogFactory.getLog(LdapServerManager.class);
+
+ private ContextSource contextSource;
+
+ public void setContextSource(ContextSource contextSource) {
+ this.contextSource = contextSource;
+ }
+
+ public void destroy() throws Exception {
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ ServerContextFactory.class.getName());
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+ env.setProperty(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
+ env.setProperty(Context.SECURITY_CREDENTIALS, "secret");
+
+ ShutdownConfiguration configuration = new ShutdownConfiguration();
+ env.putAll(configuration.toJndiEnvironment());
+
+ new InitialContext(env);
+ }
+
+ public void cleanAndSetup(String ldifFile) throws Exception {
+ DirContext ctx = contextSource.getReadWriteContext();
+
+ // First of all, make sure the database is empty.
+ Name startingPoint = null;
+
+ // Different test cases have different base paths. This means that the
+ // starting point will be different.
+ if (ctx.getEnvironment().get(
+ DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY) != null) {
+ startingPoint = DistinguishedName.EMPTY_PATH;
+ } else {
+ startingPoint = new DistinguishedName("dc=acegisecurity,dc=org");
+ }
+
+ try {
+ log.info("Cleaning all present data.");
+ clearSubContexts(ctx, startingPoint);
+ // Load the ldif to the recently started server
+ log.info("Loading setup data");
+ LdifFileLoader loader = new LdifFileLoader(ctx, ldifFile);
+ loader.execute();
+ } finally {
+ ctx.close();
+ }
+ }
+
+ private void clearSubContexts(DirContext ctx, Name name) throws NamingException {
+
+ NamingEnumeration enumeration = null;
+ try {
+ enumeration = ctx.listBindings(name);
+ while (enumeration.hasMore()) {
+ Binding element = (Binding) enumeration.next();
+ DistinguishedName childName = new DistinguishedName(element.getName());
+ childName.prepend((DistinguishedName) name);
+
+ try {
+ ctx.destroySubcontext(childName);
+ } catch (ContextNotEmptyException e) {
+ clearSubContexts(ctx, childName);
+ ctx.destroySubcontext(childName);
+ }
+ }
+ } catch(NameNotFoundException ignored) {
+ }
+ catch (NamingException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ enumeration.close();
+ } catch (Exception e) {
+ // Never mind this
+ }
+ }
+ }
+}
+
diff --git a/core/src/test/java/org/acegisecurity/ldap/LdapTemplateTests.java b/core/src/test/java/org/acegisecurity/ldap/LdapTemplateTests.java
index 84fa4ffb20..bebfb63548 100644
--- a/core/src/test/java/org/acegisecurity/ldap/LdapTemplateTests.java
+++ b/core/src/test/java/org/acegisecurity/ldap/LdapTemplateTests.java
@@ -15,8 +15,8 @@
package org.acegisecurity.ldap;
-import org.springframework.ldap.ContextExecutor;
import org.springframework.ldap.UncategorizedLdapException;
+import org.springframework.ldap.core.ContextExecutor;
import java.util.Set;
@@ -28,17 +28,16 @@ import javax.naming.directory.DirContext;
* @author Luke Taylor
* @version $Id$
*/
-public class LdapTemplateTests extends AbstractLdapServerTestCase {
+public class LdapTemplateTests extends AbstractLdapIntegrationTests {
//~ Instance fields ================================================================================================
private SpringSecurityLdapTemplate template;
//~ Methods ========================================================================================================
- protected void onSetUp() {
- getInitialCtxFactory().setManagerDn(MANAGER_USER);
- getInitialCtxFactory().setManagerPassword(MANAGER_PASSWORD);
- template = new SpringSecurityLdapTemplate(getInitialCtxFactory());
+ protected void onSetUp() throws Exception {
+ super.onSetUp();
+ template = new SpringSecurityLdapTemplate(getContextSource());
}
public void testCompareOfCorrectByteValueSucceeds() {
diff --git a/core/src/test/java/org/acegisecurity/ldap/LdapTestServer.java b/core/src/test/java/org/acegisecurity/ldap/LdapTestServer.java
deleted file mode 100644
index 0e51dad031..0000000000
--- a/core/src/test/java/org/acegisecurity/ldap/LdapTestServer.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.acegisecurity.ldap;
-
-import org.apache.directory.server.core.configuration.Configuration;
-import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
-import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
-import org.apache.directory.server.core.jndi.CoreContextFactory;
-import org.apache.directory.server.core.partition.DefaultPartitionNexus;
-
-import java.io.File;
-
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InitialDirContext;
-
-
-/**
- * An embedded LDAP test server, complete with test data for running the unit tests against.
- *
- * @author Luke Taylor
- * @version $Id$
- */
-public class LdapTestServer {
- //~ Instance fields ================================================================================================
-
- private DirContext serverContext;
-
- private MutableStartupConfiguration cfg;
-
- //~ Constructors ===================================================================================================
-
- /**
- * Starts up and configures ApacheDS.
- */
- public LdapTestServer() {
- startLdapServer();
- createManagerUser();
- initTestData();
- }
-
- //~ Methods ========================================================================================================
-
- public void createGroup(String cn, String groupContext, String ou, String[] memberDns) {
- Attributes group = new BasicAttributes("cn", cn);
- Attribute members = new BasicAttribute("member");
- Attribute orgUnit = new BasicAttribute("ou", ou);
-
- for (int i = 0; i < memberDns.length; i++) {
- members.add(memberDns[i]);
- }
-
- Attribute objectClass = new BasicAttribute("objectClass");
- objectClass.add("top");
- objectClass.add("groupOfNames");
-
- group.put(objectClass);
- group.put(members);
- group.put(orgUnit);
-
- try {
- DirContext ctx = serverContext.createSubcontext("cn=" + cn + "," + groupContext, group);
- System.out.println("Created group " + ctx.getNameInNamespace());
- } catch (NameAlreadyBoundException ignore) {
-// System.out.println(" group " + cn + " already exists.");
- } catch (NamingException ne) {
- System.err.println("Failed to create group.");
- ne.printStackTrace();
- }
- }
-
- private void createManagerUser() {
- Attributes user = new BasicAttributes("cn", "manager", true);
- user.put("userPassword", "acegisecurity");
-
- Attribute objectClass = new BasicAttribute("objectClass");
- user.put(objectClass);
- objectClass.add("top");
- objectClass.add("person");
- objectClass.add("organizationalPerson");
- objectClass.add("inetOrgPerson");
- user.put("sn", "Manager");
- user.put("cn", "manager");
-
- try {
- serverContext.createSubcontext("cn=manager", user);
- } catch (NameAlreadyBoundException ignore) {
- // System.out.println("Manager user already exists.");
- } catch (NamingException ne) {
- System.err.println("Failed to create manager user.");
- ne.printStackTrace();
- }
- }
-
- public void createOu(String name) {
- Attributes ou = new BasicAttributes("ou", name);
- Attribute objectClass = new BasicAttribute("objectClass");
- objectClass.add("top");
- objectClass.add("organizationalUnit");
- ou.put(objectClass);
-
- try {
- serverContext.createSubcontext(name, ou);
- } catch (NameAlreadyBoundException ignore) {
- // System.out.println(" ou " + name + " already exists.");
- } catch (NamingException ne) {
- System.err.println("Failed to create ou.");
- ne.printStackTrace();
- }
- }
-
- public void createUser(String uid, String cn, String password) {
- Attributes user = new BasicAttributes("uid", uid);
- user.put("cn", cn);
- user.put("userPassword", LdapUtils.getUtf8Bytes(password));
-
- Attribute objectClass = new BasicAttribute("objectClass");
- user.put(objectClass);
- objectClass.add("top");
- objectClass.add("person");
- objectClass.add("organizationalPerson");
- objectClass.add("inetOrgPerson");
- user.put("sn", uid);
-
- try {
- serverContext.createSubcontext("uid=" + uid + ",ou=people", user);
- } catch (NameAlreadyBoundException ignore) {
-// System.out.println(" user " + uid + " already exists.");
- } catch (NamingException ne) {
- System.err.println("Failed to create user.");
- ne.printStackTrace();
- }
- }
-
- public Configuration getConfiguration() {
- return cfg;
- }
-
- private void initConfiguration() throws NamingException {
- // Create the partition for the acegi tests
- MutablePartitionConfiguration acegiDit = new MutablePartitionConfiguration();
- acegiDit.setName("acegisecurity");
- acegiDit.setSuffix("dc=acegisecurity,dc=org");
-
- BasicAttributes attributes = new BasicAttributes();
- BasicAttribute objectClass = new BasicAttribute("objectClass");
- objectClass.add("top");
- objectClass.add("domain");
- objectClass.add("extensibleObject");
- attributes.put(objectClass);
- acegiDit.setContextEntry(attributes);
-
- Set indexedAttrs = new HashSet();
- indexedAttrs.add("objectClass");
- indexedAttrs.add("uid");
- indexedAttrs.add("cn");
- indexedAttrs.add("ou");
- indexedAttrs.add("member");
-
- acegiDit.setIndexedAttributes(indexedAttrs);
-
- Set partitions = new HashSet();
- partitions.add(acegiDit);
-
- cfg.setContextPartitionConfigurations(partitions);
- }
-
- private void initTestData() {
- createOu("ou=people");
- createOu("ou=groups");
- createOu("ou=subgroups,ou=groups");
-
- createUser("bob", "Bob Hamilton", "bobspassword");
- createUser("ben", "Ben Alex", "{SHA}nFCebWjxfaLbHHG1Qk5UU4trbvQ=");
-
- String[] developers = new String[]{
- "uid=ben,ou=people,dc=acegisecurity,dc=org", "uid=bob,ou=people,dc=acegisecurity,dc=org"
- };
- createGroup("developers", "ou=groups", "developer", developers);
- createGroup("managers", "ou=groups", "manager", new String[]{developers[0]});
- createGroup("submanagers", "ou=subgroups,ou=groups", "submanager", new String[]{developers[0]});
- }
-
- public static void main(String[] args) {
- LdapTestServer server = new LdapTestServer();
- }
-
- private void startLdapServer() {
- cfg = new MutableStartupConfiguration();
-
- // Attempt to use the maven target directory for the apache ds store. Property is passed
- // through surefire plugin setup in pom.xml.
-
- String apacheWorkDir = System.getProperty("apacheDSWorkDir");
-
- if (apacheWorkDir == null) {
- apacheWorkDir = System.getProperty("java.io.tmpdir") + File.separator + "apacheds-work";
- }
-
- File workingDir = new File(apacheWorkDir);
-
- // Delete any previous contents (often not compatible between apache-ds versions).
- deleteDir(workingDir);
-
- ((MutableStartupConfiguration) cfg).setWorkingDirectory(workingDir);
-
- System.out.println("Ldap Server Working directory is " + workingDir.getAbsolutePath());
-
- Properties env = new Properties();
-
- env.setProperty(Context.PROVIDER_URL, "dc=acegisecurity,dc=org");
- env.setProperty(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());
- env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
- env.setProperty(Context.SECURITY_PRINCIPAL, DefaultPartitionNexus.ADMIN_PRINCIPAL);
- env.setProperty(Context.SECURITY_CREDENTIALS, DefaultPartitionNexus.ADMIN_PASSWORD);
-
- try {
- initConfiguration();
- env.putAll(cfg.toJndiEnvironment());
- serverContext = new InitialDirContext(env);
- } catch (NamingException e) {
- System.err.println("Failed to start Apache DS");
- e.printStackTrace();
- }
- }
-
- /**
- * Recursively deletes a directory
- */
- private boolean deleteDir(File dir) {
- if (dir.isDirectory()) {
- String[] children = dir.list();
- for (int i = 0; i < children.length; i++) {
- boolean success = deleteDir(new File(dir, children[i]));
- if (!success) {
- return false;
- }
- }
- }
-
- return dir.delete();
- }
-}
diff --git a/core/src/test/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearchTests.java b/core/src/test/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearchTests.java
index f053294615..b2114af662 100644
--- a/core/src/test/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearchTests.java
+++ b/core/src/test/java/org/acegisecurity/ldap/search/FilterBasedLdapUserSearchTests.java
@@ -15,8 +15,8 @@
package org.acegisecurity.ldap.search;
-import org.acegisecurity.ldap.AbstractLdapServerTestCase;
import org.acegisecurity.ldap.DefaultInitialDirContextFactory;
+import org.acegisecurity.ldap.AbstractLdapIntegrationTests;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.acegisecurity.userdetails.ldap.LdapUserDetails;
@@ -30,26 +30,16 @@ import org.springframework.dao.IncorrectResultSizeDataAccessException;
* @author Luke Taylor
* @version $Id$
*/
-public class FilterBasedLdapUserSearchTests extends AbstractLdapServerTestCase {
+public class FilterBasedLdapUserSearchTests extends AbstractLdapIntegrationTests {
//~ Instance fields ================================================================================================
private DefaultInitialDirContextFactory dirCtxFactory;
- //~ Constructors ===================================================================================================
-
- public FilterBasedLdapUserSearchTests(String string) {
- super(string);
- }
-
- public FilterBasedLdapUserSearchTests() {
- }
-
//~ Methods ========================================================================================================
- public void onSetUp() {
- dirCtxFactory = getInitialCtxFactory();
- dirCtxFactory.setManagerDn(MANAGER_USER);
- dirCtxFactory.setManagerPassword(MANAGER_PASSWORD);
+ public void onSetUp() throws Exception {
+ super.onSetUp();
+ dirCtxFactory = (DefaultInitialDirContextFactory) getContextSource();
}
public void testBasicSearch() {
diff --git a/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticatorTests.java b/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticatorTests.java
index 574e5fb9ed..20f53c41f2 100644
--- a/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticatorTests.java
+++ b/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/BindAuthenticatorTests.java
@@ -19,7 +19,8 @@ import org.acegisecurity.AcegiMessageSource;
import org.acegisecurity.BadCredentialsException;
import org.acegisecurity.GrantedAuthorityImpl;
-import org.acegisecurity.ldap.AbstractLdapServerTestCase;
+import org.acegisecurity.ldap.AbstractLdapIntegrationTests;
+import org.acegisecurity.ldap.InitialDirContextFactory;
import org.acegisecurity.userdetails.ldap.LdapUserDetails;
import org.acegisecurity.userdetails.ldap.LdapUserDetailsImpl;
@@ -32,7 +33,7 @@ import org.acegisecurity.userdetails.ldap.LdapUserDetailsMapper;
* @author Luke Taylor
* @version $Id$
*/
-public class BindAuthenticatorTests extends AbstractLdapServerTestCase {
+public class BindAuthenticatorTests extends AbstractLdapIntegrationTests {
//~ Instance fields ================================================================================================
private BindAuthenticator authenticator;
@@ -40,7 +41,7 @@ public class BindAuthenticatorTests extends AbstractLdapServerTestCase {
//~ Methods ========================================================================================================
public void onSetUp() {
- authenticator = new BindAuthenticator(getInitialCtxFactory());
+ authenticator = new BindAuthenticator((InitialDirContextFactory) getContextSource());
authenticator.setMessageSource(new AcegiMessageSource());
}
@@ -95,6 +96,6 @@ public class BindAuthenticatorTests extends AbstractLdapServerTestCase {
public void testUserDnPatternReturnsCorrectDn() {
authenticator.setUserDnPatterns(new String[] {"cn={0},ou=people"});
- assertEquals("cn=Joe,ou=people," + getInitialCtxFactory().getRootDn(), authenticator.getUserDns("Joe").get(0));
+ assertEquals("cn=Joe,ou=people," + ((InitialDirContextFactory)getContextSource()).getRootDn(), authenticator.getUserDns("Joe").get(0));
}
}
diff --git a/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/PasswordComparisonAuthenticatorTests.java b/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/PasswordComparisonAuthenticatorTests.java
index 9fdac34966..216b32554b 100644
--- a/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/PasswordComparisonAuthenticatorTests.java
+++ b/core/src/test/java/org/acegisecurity/providers/ldap/authenticator/PasswordComparisonAuthenticatorTests.java
@@ -17,7 +17,8 @@ package org.acegisecurity.providers.ldap.authenticator;
import org.acegisecurity.BadCredentialsException;
-import org.acegisecurity.ldap.AbstractLdapServerTestCase;
+import org.acegisecurity.ldap.AbstractLdapIntegrationTests;
+import org.acegisecurity.ldap.InitialDirContextFactory;
import org.acegisecurity.providers.encoding.PlaintextPasswordEncoder;
@@ -33,33 +34,33 @@ import org.acegisecurity.userdetails.ldap.LdapUserDetailsMapper;
* @author Luke Taylor
* @version $Id$
*/
-public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTestCase {
+public class PasswordComparisonAuthenticatorTests extends AbstractLdapIntegrationTests {
//~ Instance fields ================================================================================================
private PasswordComparisonAuthenticator authenticator;
//~ Methods ========================================================================================================
- public void onSetUp() {
- getInitialCtxFactory().setManagerDn(MANAGER_USER);
- getInitialCtxFactory().setManagerPassword(MANAGER_PASSWORD);
- authenticator = new PasswordComparisonAuthenticator(getInitialCtxFactory());
+ public void onSetUp() throws Exception {
+ super.onSetUp();
+ authenticator = new PasswordComparisonAuthenticator((InitialDirContextFactory) getContextSource());
authenticator.setUserDnPatterns(new String[] {"uid={0},ou=people"});
}
- public void tearDown() {
+ public void onTearDown() throws Exception {
+ super.onTearDown();
// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
}
public void testAllAttributesAreRetrivedByDefault() {
- LdapUserDetails user = authenticator.authenticate("Bob", "bobspassword");
+ LdapUserDetails user = authenticator.authenticate("bob", "bobspassword");
//System.out.println(user.getAttributes().toString());
assertEquals("User should have 5 attributes", 5, user.getAttributes().size());
}
public void testFailedSearchGivesUserNotFoundException()
throws Exception {
- authenticator = new PasswordComparisonAuthenticator(getInitialCtxFactory());
+ authenticator = new PasswordComparisonAuthenticator((InitialDirContextFactory) getContextSource());
assertTrue("User DN matches shouldn't be available", authenticator.getUserDns("Bob").isEmpty());
authenticator.setUserSearch(new MockUserSearch(null));
authenticator.afterPropertiesSet();
@@ -82,7 +83,7 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
} catch (BadCredentialsException expected) {}
}
-/*
+
public void testLdapPasswordCompareFailsWithWrongPassword() {
// Don't retrieve the password
authenticator.setUserAttributes(new String[] {"cn", "sn"});
@@ -92,7 +93,7 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
} catch(BadCredentialsException expected) {
}
}
- */
+
public void testLocalPasswordComparisonSucceedsWithCorrectPassword() {
LdapUserDetails user = authenticator.authenticate("Bob", "bobspassword");
// check username is retrieved.
@@ -105,35 +106,28 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
authenticator.authenticate("Bob", "bobspassword");
}
- public void testOnlySpecifiedAttributesAreRetrieved()
- throws Exception {
+ public void testOnlySpecifiedAttributesAreRetrieved() throws Exception {
authenticator.setUserAttributes(new String[] {"userPassword"});
authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
LdapUserDetails user = authenticator.authenticate("Bob", "bobspassword");
assertEquals("Should have retrieved 1 attribute (userPassword)", 1, user.getAttributes().size());
-
-// assertEquals("Bob Hamilton", user.getAttributes().get("cn").get());
-// assertEquals("bob", user.getAttributes().get("uid").get());
}
- /*
- public void testLdapCompareSucceedsWithCorrectPassword() {
- // Don't retrieve the password
- authenticator.setUserAttributes(new String[] {"cn"});
- // Bob has a plaintext password.
- authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
- authenticator.authenticate("bob", "bobspassword");
- }
- public void testLdapCompareSucceedsWithShaEncodedPassword() {
- authenticator = new PasswordComparisonAuthenticator();
- authenticator.setInitialDirContextFactory(dirCtxFactory);
- authenticator.setUserDnPatterns("uid={0},ou=people");
- // Don't retrieve the password
- authenticator.setUserAttributes(new String[] {"cn"});
- authenticator.authenticate("ben", "benspassword");
- }
- */
+ public void testLdapCompareSucceedsWithCorrectPassword() {
+ // Don't retrieve the password
+ authenticator.setUserAttributes(new String[] {"cn"});
+ // Bob has a plaintext password.
+ authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
+ authenticator.authenticate("bob", "bobspassword");
+ }
+
+ public void testLdapCompareSucceedsWithShaEncodedPassword() {
+ // Don't retrieve the password
+ authenticator.setUserAttributes(new String[] {"cn"});
+ authenticator.authenticate("ben", "benspassword");
+ }
+
public void testPasswordEncoderCantBeNull() {
try {
authenticator.setPasswordEncoder(null);
@@ -150,16 +144,15 @@ public class PasswordComparisonAuthenticatorTests extends AbstractLdapServerTest
LdapUserDetails bob = authenticator.authenticate("bob", "bob");
}
-/*
public void testLdapCompareWithDifferentPasswordAttributeSucceeds() {
authenticator.setUserAttributes(new String[] {"cn"});
authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
authenticator.setPasswordAttributeName("uid");
authenticator.authenticate("bob", "bob");
}
- */
+
public void testWithUserSearch() {
- authenticator = new PasswordComparisonAuthenticator(getInitialCtxFactory());
+ authenticator = new PasswordComparisonAuthenticator((InitialDirContextFactory) getContextSource());
assertTrue("User DN matches shouldn't be available", authenticator.getUserDns("Bob").isEmpty());
LdapUserDetailsImpl.Essence userEssence = new LdapUserDetailsImpl.Essence();
diff --git a/core/src/test/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java b/core/src/test/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java
index 2c081addf8..5158333530 100644
--- a/core/src/test/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java
+++ b/core/src/test/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java
@@ -17,14 +17,13 @@ package org.acegisecurity.providers.ldap.populator;
import org.acegisecurity.GrantedAuthority;
-import org.acegisecurity.ldap.AbstractLdapServerTestCase;
+import org.acegisecurity.ldap.AbstractLdapIntegrationTests;
+import org.acegisecurity.ldap.InitialDirContextFactory;
import org.acegisecurity.userdetails.ldap.LdapUserDetailsImpl;
import java.util.HashSet;
import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
import javax.naming.directory.BasicAttributes;
@@ -35,12 +34,15 @@ import javax.naming.directory.BasicAttributes;
* @author Luke Taylor
* @version $Id$
*/
-public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapServerTestCase {
+public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapIntegrationTests {
+ private DefaultLdapAuthoritiesPopulator populator;
//~ Methods ========================================================================================================
- public void onSetUp() {
- getInitialCtxFactory().setManagerDn(MANAGER_USER);
- getInitialCtxFactory().setManagerPassword(MANAGER_PASSWORD);
+ protected void onSetUp() throws Exception {
+ super.onSetUp();
+
+ populator = new DefaultLdapAuthoritiesPopulator((InitialDirContextFactory) getContextSource(), "ou=groups");
+
}
// public void testUserAttributeMappingToRoles() {
@@ -67,8 +69,7 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapServerTest
// }
public void testDefaultRoleIsAssignedWhenSet() {
- DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(getInitialCtxFactory(),
- "ou=groups");
+
populator.setDefaultRole("ROLE_USER");
LdapUserDetailsImpl.Essence user = new LdapUserDetailsImpl.Essence();
@@ -82,8 +83,6 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapServerTest
}
public void testGroupSearchReturnsExpectedRoles() {
- DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(getInitialCtxFactory(),
- "ou=groups");
populator.setRolePrefix("ROLE_");
populator.setGroupRoleAttribute("ou");
populator.setSearchSubtree(true);
@@ -108,8 +107,6 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapServerTest
}
public void testUseOfUsernameParameterReturnsExpectedRoles() {
- DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(getInitialCtxFactory(),
- "ou=groups");
populator.setGroupRoleAttribute("ou");
populator.setConvertToUpperCase(true);
populator.setGroupSearchFilter("(ou={1})");
@@ -124,8 +121,6 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapServerTest
}
public void testSubGroupRolesAreNotFoundByDefault() {
- DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(getInitialCtxFactory(),
- "ou=groups");
populator.setGroupRoleAttribute("ou");
populator.setConvertToUpperCase(true);
@@ -143,8 +138,6 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapServerTest
}
public void testSubGroupRolesAreFoundWhenSubtreeSearchIsEnabled() {
- DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(getInitialCtxFactory(),
- "ou=groups");
populator.setGroupRoleAttribute("ou");
populator.setConvertToUpperCase(true);
populator.setSearchSubtree(true);
diff --git a/core/src/test/resources/org/acegisecurity/ldap/apacheDsContext.xml b/core/src/test/resources/org/acegisecurity/ldap/apacheDsContext.xml
new file mode 100644
index 0000000000..08f546f0f4
--- /dev/null
+++ b/core/src/test/resources/org/acegisecurity/ldap/apacheDsContext.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+ simple
+
+
+ ${userDn}
+
+
+ ${password}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ objectClass: top
+ objectClass: domain
+ objectClass: extensibleObject
+ dc: acegisecurity
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/test/resources/org/acegisecurity/ldap/ldapIntegrationTestContext.xml b/core/src/test/resources/org/acegisecurity/ldap/ldapIntegrationTestContext.xml
new file mode 100644
index 0000000000..ed2d9b14da
--- /dev/null
+++ b/core/src/test/resources/org/acegisecurity/ldap/ldapIntegrationTestContext.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/test/resources/org/acegisecurity/ldap/ldapserver.properties b/core/src/test/resources/org/acegisecurity/ldap/ldapserver.properties
new file mode 100644
index 0000000000..3caa9683b2
--- /dev/null
+++ b/core/src/test/resources/org/acegisecurity/ldap/ldapserver.properties
@@ -0,0 +1,5 @@
+urls=ldap://127.0.0.1:3900
+userDn=uid=admin,ou=system
+password=secret
+base=dc=acegisecurity,dc=org
+fullUrl=ldap://127.0.0.1:3900/dc=acegisecurity,dc=org
\ No newline at end of file