Refactored embedded LDAP server tests to make use of new namespace configuration. Use Junit 4 annotations in preference to AbstractDependencyInjectionSpringContextTests so that it is possible to clear up the context after each class is run rather than at JVM shutdown (causes problems with running embedded apache DS).

This commit is contained in:
Luke Taylor
2007-10-02 10:52:06 +00:00
parent 77b6503e2e
commit acb02246e0
24 changed files with 272 additions and 572 deletions

View File

@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This context automatically starts the Apache Directory Server
and sets up the test data
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- JNDI environment variable -->
<bean id="environment"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="java.naming.security.authentication">
simple
</prop>
<prop key="java.naming.security.principal">
${userDn}
</prop>
<prop key="java.naming.security.credentials">
${password}
</prop>
</props>
</property>
</bean>
<!--
Note the non-standard port, in order to leave 389 unused, thus
making it easier for the integration tests requiring OpenLDAP.
-->
<bean id="configuration" class="org.apache.directory.server.configuration.MutableServerStartupConfiguration">
<property name="ldapPort" value="3999" />
<property name="contextPartitionConfigurations">
<set>
<bean class="org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration">
<property name="name" value="acegisecurity" />
<property name="suffix" value="dc=acegisecurity,dc=org" />
<property name="contextEntry">
<value>
objectClass: top
objectClass: domain
objectClass: extensibleObject
dc: acegisecurity
</value>
</property>
</bean>
</set>
</property>
</bean>
<bean id="configEnvHelper" class="org.springframework.security.ldap.ConfigEnvHelper">
<constructor-arg ref="environment" />
<constructor-arg ref="configuration" />
</bean>
<bean name="serverContext" class="javax.naming.InitialContext">
<constructor-arg>
<bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
<property name="targetObject" ref="configEnvHelper" />
<property name="propertyPath" value="env" />
</bean>
</constructor-arg>
</bean>
<bean name="ldapServerManager" class="org.springframework.security.ldap.LdapServerManager">
<property name="contextSource" ref="contextSource" />
</bean>
<!-- Custom editors required to launch ApacheDS -->
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="javax.naming.directory.Attributes">
<bean class="org.apache.directory.server.core.configuration.AttributesPropertyEditor"/>
</entry>
</map>
</property>
</bean>
</beans>

View File

@@ -1,34 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">
<import resource="classpath:/org/springframework/security/ldap/apacheDsContext.xml"/>
<security:ldap ldif="classpath:test-server.ldif"/>
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/org/springframework/security/ldap/ldapserver.properties" />
</bean>
<!--
<bean id="contextSource" class="org.springframework.ldap.core.support.DirContextSource" >
<property name="urls" value="${urls}" />
<property name="userDn" value="${userDn}" />
<property name="password" value="${password}" />
<property name="base" value="${base}" />
<property name="dirObjectFactory" value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
</bean>
-->
<bean id="contextSource" class="org.springframework.security.ldap.DefaultInitialDirContextFactory" >
<constructor-arg value="${fullUrl}"/>
<property name="managerDn" value="${userDn}"/>
<property name="managerPassword" value="${password}" />
<property name="useLdapContext" value="true"/>
<property name="dirObjectFactory" value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
</bean>
<!--<import resource="classpath:/org/springframework/security/ldap/apacheDsContext.xml"/>-->
<!-- Here for refactoring, until we have a satisfactory context source implementation -->
<bean id="initialDirContextFactory" class="org.springframework.security.ldap.DefaultInitialDirContextFactory" >
<constructor-arg value="${fullUrl}"/>
<constructor-arg value="ldap://127.0.0.1:3389/dc=springframework,dc=org"/>
<property name="useLdapContext" value="true"/>
<property name="dirObjectFactory" value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
</bean>

View File

@@ -1,5 +0,0 @@
urls=ldap://127.0.0.1:3999
userDn=uid=admin,ou=system
password=secret
base=dc=acegisecurity,dc=org
fullUrl=ldap://127.0.0.1:3999/dc=acegisecurity,dc=org

View File

@@ -1,56 +0,0 @@
dn: ou=groups,dc=acegisecurity,dc=org
objectclass: top
objectclass: organizationalUnit
ou: groups
dn: ou=subgroups,ou=groups,dc=acegisecurity,dc=org
objectclass: top
objectclass: organizationalUnit
ou: subgroups
dn: ou=people,dc=acegisecurity,dc=org
objectclass: top
objectclass: organizationalUnit
ou: groups
dn: uid=ben,ou=people,dc=acegisecurity,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Ben Alex
sn: Alex
uid: ben
userPassword: {SHA}nFCebWjxfaLbHHG1Qk5UU4trbvQ=
dn: uid=bob,ou=people,dc=acegisecurity,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Bob Hamilton
sn: Hamilton
uid: bob
userPassword: bobspassword
dn: cn=developers,ou=groups,dc=acegisecurity,dc=org
objectclass: top
objectclass: groupOfNames
cn: developers
ou: developer
member: uid=ben,ou=people,dc=acegisecurity,dc=org
member: uid=bob,ou=people,dc=acegisecurity,dc=org
dn: cn=managers,ou=groups,dc=acegisecurity,dc=org
objectclass: top
objectclass: groupOfNames
cn: managers
ou: manager
member: uid=ben,ou=people,dc=acegisecurity,dc=org
dn: cn=submanagers,ou=subgroups,ou=groups,dc=acegisecurity,dc=org
objectclass: top
objectclass: groupOfNames
cn: submanagers
ou: submanager
member: uid=ben,ou=people,dc=acegisecurity,dc=org

View File

@@ -1,56 +0,0 @@
version: 1
dn: dc=acegisecurity,dc=org
objectClass: dcObject
objectClass: organization
dc: acegisecurity
description: Acegi Security (Test LDAP DIT)
o: Monkey Machine Ltd.
dn: ou=people,dc=acegisecurity,dc=org
objectClass: organizationalUnit
description: All people in organisation
ou: people
dn: cn=Ben Alex,ou=people,dc=acegisecurity,dc=org
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
cn: Ben Alex
ou:: 5a6J5YWo
sn: Alex
uid: Ben
userPassword:: e1NIQX1uRkNlYldqeGZhTGJISEcxUWs1VVU0dHJidlE9
dn: uid=bob,ou=people,dc=acegisecurity,dc=org
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
cn: Bob Hamilton
sn: Hamilton
uid: bob
userPassword:: Ym9ic3Bhc3N3b3Jk
dn: ou=groups,dc=acegisecurity,dc=org
objectClass: top
objectClass: organizationalUnit
ou: groups
dn: cn=developers,ou=groups,dc=acegisecurity,dc=org
objectClass: groupOfNames
objectClass: top
cn: developers
description: Acegi Security Developers
member: uid=bob,ou=people,dc=acegisecurity,dc=org
member: cn=ben alex,ou=people,dc=acegisecurity,dc=org
o: Acegi Security System for Spring
ou: developer
dn: cn=managers,ou=groups,dc=acegisecurity,dc=org
objectClass: groupOfNames
objectClass: top
cn: managers
member: cn=ben alex,ou=people,dc=acegisecurity,dc=org
ou: manager