LDAP-262: Added smoke tests for compatibility with Spring 2.0, 2.5, and 3.0
This commit is contained in:
@@ -1208,9 +1208,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (contextSource == null) {
|
||||
throw new IllegalArgumentException("Property 'contextSource' must be set.");
|
||||
}
|
||||
Assert.notNull(contextSource, "Property 'contextSource' must be set.");
|
||||
}
|
||||
|
||||
private void closeContextAndNamingEnumeration(DirContext ctx, NamingEnumeration results) {
|
||||
|
||||
@@ -8,6 +8,9 @@ include 'ldif/ldif-core'
|
||||
include 'odm'
|
||||
include 'sandbox'
|
||||
include 'test/integration-tests'
|
||||
include 'test/integration-tests-spring20'
|
||||
include 'test/integration-tests-spring25'
|
||||
include 'test/integration-tests-spring30'
|
||||
include 'test/integration-tests-openldap'
|
||||
include 'test/integration-tests-sunone'
|
||||
include 'test/integration-tests-ad'
|
||||
@@ -29,4 +32,4 @@ rootProject.children.each { p->
|
||||
p.name = "spring-ldap-" + name
|
||||
}
|
||||
|
||||
findProject(":spring-ldap-test-support").name = "spring-ldap-test"
|
||||
findProject(":spring-ldap-test-support").name = "spring-ldap-test"
|
||||
|
||||
22
test/integration-tests-spring20/build.gradle
Normal file
22
test/integration-tests-spring20/build.gradle
Normal file
@@ -0,0 +1,22 @@
|
||||
repositories {
|
||||
maven { url "http://download.java.net/maven/2/" }
|
||||
}
|
||||
apply from: JAVA_SCRIPT
|
||||
|
||||
ext.spring20Version = '2.0.8'
|
||||
|
||||
dependencies {
|
||||
testCompile (project(":spring-ldap-test")) {
|
||||
exclude group: "org.springframework", module:"spring-core"
|
||||
exclude group: "org.springframework", module:"spring-beans"
|
||||
exclude group: "org.springframework", module:"spring-context"
|
||||
exclude group: "org.springframework", module:"spring-test"
|
||||
exclude group: "org.springframework", module:"spring-tx"
|
||||
}
|
||||
|
||||
testCompile "org.springframework:spring-mock:$spring20Version",
|
||||
"org.springframework:spring-context:$spring20Version",
|
||||
"org.springframework:spring-core:$spring20Version",
|
||||
"org.springframework:spring-dao:$spring20Version",
|
||||
"org.springframework:spring-beans:$spring20Version"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2005-2013 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.springframework.ldap.itest20;
|
||||
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate together with Spring 2.0.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class LdapTemplateLookup20ITest extends AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"/conf/ldapTemplateTestContext.xml"};
|
||||
}
|
||||
|
||||
/**
|
||||
* This method depends on a DirObjectFactory (
|
||||
* {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
|
||||
* being set in the ContextSource.
|
||||
*/
|
||||
public void testThatPlainLookupWorksWithSpring20() {
|
||||
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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">
|
||||
|
||||
<!--
|
||||
This context configuration file defines common beans,
|
||||
minimizing duplication in the various test context files.
|
||||
-->
|
||||
|
||||
<bean id="placeholderConfig"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:/conf/ldap.properties" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,4 @@
|
||||
urls=ldap://127.0.0.1:1888
|
||||
userDn=uid=admin,ou=system
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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">
|
||||
<import resource="classpath:/conf/commonTestContext.xml" />
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="1888" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,12 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout.ConversionPattern=%r [%t] %-5p\: %-15c{2} - %m%n
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Enable info on Spring LDAP
|
||||
#log4j.logger.org.springframework.ldap=INFO
|
||||
|
||||
log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
|
||||
log4j.logger.org.apache.directory.server.core.schema.bootstrap=ERROR
|
||||
log4j.logger.org.apache.directory.server.core.partition.impl.btree=ERROR
|
||||
log4j.logger.org.apache.directory.shared.ldap.ldif=ERROR
|
||||
@@ -0,0 +1,110 @@
|
||||
dn: ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: groups
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
|
||||
dn: c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Sweden
|
||||
description: The country of Sweden
|
||||
|
||||
dn: c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Norway
|
||||
description: The country of Norway
|
||||
|
||||
dn: ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company2
|
||||
description: Second company in Sweden
|
||||
|
||||
dn: ou=company1,c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Norway
|
||||
|
||||
dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company1, Some Person
|
||||
telephoneNumber: +46 555-123456
|
||||
|
||||
dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person2
|
||||
userPassword: password
|
||||
cn: Some Person2
|
||||
sn: Person2
|
||||
description: Sweden, Company1, Some Person2
|
||||
telephoneNumber: +46 555-654321
|
||||
|
||||
dn: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person3
|
||||
userPassword: password
|
||||
cn: Some Person3
|
||||
sn: Person3
|
||||
description: Sweden, Company1, Some Person3
|
||||
telephoneNumber: +46 555-123654
|
||||
|
||||
dn: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person4
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company2, Some Person
|
||||
telephoneNumber: +46 555-456321
|
||||
|
||||
dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.norwegian
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Norway, Company1, Some Person+Person
|
||||
telephoneNumber: +45 555-654123
|
||||
27
test/integration-tests-spring25/build.gradle
Normal file
27
test/integration-tests-spring25/build.gradle
Normal file
@@ -0,0 +1,27 @@
|
||||
repositories {
|
||||
maven { url "http://download.java.net/maven/2/" }
|
||||
}
|
||||
apply from: JAVA_SCRIPT
|
||||
|
||||
ext.spring25Version = '2.5.6.SEC03'
|
||||
|
||||
dependencies {
|
||||
testCompile (project(":spring-ldap-test")) {
|
||||
exclude group: "org.springframework", module:"spring-core"
|
||||
exclude group: "org.springframework", module:"spring-beans"
|
||||
exclude group: "org.springframework", module:"spring-context"
|
||||
exclude group: "org.springframework", module:"spring-test"
|
||||
exclude group: "org.springframework", module:"spring-tx"
|
||||
}
|
||||
|
||||
testCompile ("org.springframework:spring-test:$spring25Version") {
|
||||
exclude group: "junit", module:"junit"
|
||||
}
|
||||
|
||||
testCompile "org.springframework:spring-test:$spring25Version",
|
||||
"org.springframework:spring-context:$spring25Version",
|
||||
"org.springframework:spring-core:$spring25Version",
|
||||
"org.springframework:spring-tx:$spring25Version",
|
||||
"org.springframework:spring-beans:$spring25Version",
|
||||
"junit:junit:$junitVersion"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2005-2013 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.springframework.ldap.itest25;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate together with Spring 2.5.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
@ContextConfiguration(locations = {"/conf/ldapTemplateTestContext.xml"})
|
||||
public class LdapTemplateLookup25ITest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
/**
|
||||
* This method depends on a DirObjectFactory (
|
||||
* {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
|
||||
* being set in the ContextSource.
|
||||
*/
|
||||
@Test
|
||||
public void testThatPlainLookupWorksWithSpring25() {
|
||||
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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">
|
||||
|
||||
<!--
|
||||
This context configuration file defines common beans,
|
||||
minimizing duplication in the various test context files.
|
||||
-->
|
||||
|
||||
<bean id="placeholderConfig"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:/conf/ldap.properties" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,4 @@
|
||||
urls=ldap://127.0.0.1:1888
|
||||
userDn=uid=admin,ou=system
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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">
|
||||
<import resource="classpath:/conf/commonTestContext.xml" />
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="1888" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,12 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout.ConversionPattern=%r [%t] %-5p\: %-15c{2} - %m%n
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Enable info on Spring LDAP
|
||||
#log4j.logger.org.springframework.ldap=INFO
|
||||
|
||||
log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
|
||||
log4j.logger.org.apache.directory.server.core.schema.bootstrap=ERROR
|
||||
log4j.logger.org.apache.directory.server.core.partition.impl.btree=ERROR
|
||||
log4j.logger.org.apache.directory.shared.ldap.ldif=ERROR
|
||||
@@ -0,0 +1,110 @@
|
||||
dn: ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: groups
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
|
||||
dn: c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Sweden
|
||||
description: The country of Sweden
|
||||
|
||||
dn: c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Norway
|
||||
description: The country of Norway
|
||||
|
||||
dn: ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company2
|
||||
description: Second company in Sweden
|
||||
|
||||
dn: ou=company1,c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Norway
|
||||
|
||||
dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company1, Some Person
|
||||
telephoneNumber: +46 555-123456
|
||||
|
||||
dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person2
|
||||
userPassword: password
|
||||
cn: Some Person2
|
||||
sn: Person2
|
||||
description: Sweden, Company1, Some Person2
|
||||
telephoneNumber: +46 555-654321
|
||||
|
||||
dn: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person3
|
||||
userPassword: password
|
||||
cn: Some Person3
|
||||
sn: Person3
|
||||
description: Sweden, Company1, Some Person3
|
||||
telephoneNumber: +46 555-123654
|
||||
|
||||
dn: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person4
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company2, Some Person
|
||||
telephoneNumber: +46 555-456321
|
||||
|
||||
dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.norwegian
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Norway, Company1, Some Person+Person
|
||||
telephoneNumber: +45 555-654123
|
||||
27
test/integration-tests-spring30/build.gradle
Normal file
27
test/integration-tests-spring30/build.gradle
Normal file
@@ -0,0 +1,27 @@
|
||||
repositories {
|
||||
maven { url "http://download.java.net/maven/2/" }
|
||||
}
|
||||
apply from: JAVA_SCRIPT
|
||||
|
||||
ext.spring30Version = '3.0.7.RELEASE'
|
||||
|
||||
dependencies {
|
||||
testCompile (project(":spring-ldap-test")) {
|
||||
exclude group: "org.springframework", module:"spring-core"
|
||||
exclude group: "org.springframework", module:"spring-beans"
|
||||
exclude group: "org.springframework", module:"spring-context"
|
||||
exclude group: "org.springframework", module:"spring-test"
|
||||
exclude group: "org.springframework", module:"spring-tx"
|
||||
}
|
||||
|
||||
testCompile ("org.springframework:spring-test:$spring30Version") {
|
||||
exclude group: "junit", module:"junit"
|
||||
}
|
||||
|
||||
testCompile "org.springframework:spring-test:$spring30Version",
|
||||
"org.springframework:spring-context:$spring30Version",
|
||||
"org.springframework:spring-core:$spring30Version",
|
||||
"org.springframework:spring-tx:$spring30Version",
|
||||
"org.springframework:spring-beans:$spring30Version",
|
||||
"junit:junit:$junitVersion"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2005-2013 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.springframework.ldap.itest30;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate together with Spring 3.0.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
@ContextConfiguration(locations = {"/conf/ldapTemplateTestContext.xml"})
|
||||
public class LdapTemplateLookup30ITest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
/**
|
||||
* This method depends on a DirObjectFactory (
|
||||
* {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
|
||||
* being set in the ContextSource.
|
||||
*/
|
||||
@Test
|
||||
public void testThatPlainLookupWorksWithSpring30() {
|
||||
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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">
|
||||
|
||||
<!--
|
||||
This context configuration file defines common beans,
|
||||
minimizing duplication in the various test context files.
|
||||
-->
|
||||
|
||||
<bean id="placeholderConfig"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:/conf/ldap.properties" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,4 @@
|
||||
urls=ldap://127.0.0.1:1888
|
||||
userDn=uid=admin,ou=system
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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">
|
||||
<import resource="classpath:/conf/commonTestContext.xml" />
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="1888" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,12 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout.ConversionPattern=%r [%t] %-5p\: %-15c{2} - %m%n
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Enable info on Spring LDAP
|
||||
#log4j.logger.org.springframework.ldap=INFO
|
||||
|
||||
log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
|
||||
log4j.logger.org.apache.directory.server.core.schema.bootstrap=ERROR
|
||||
log4j.logger.org.apache.directory.server.core.partition.impl.btree=ERROR
|
||||
log4j.logger.org.apache.directory.shared.ldap.ldif=ERROR
|
||||
@@ -0,0 +1,110 @@
|
||||
dn: ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: groups
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
|
||||
dn: c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Sweden
|
||||
description: The country of Sweden
|
||||
|
||||
dn: c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Norway
|
||||
description: The country of Norway
|
||||
|
||||
dn: ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company2
|
||||
description: Second company in Sweden
|
||||
|
||||
dn: ou=company1,c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Norway
|
||||
|
||||
dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company1, Some Person
|
||||
telephoneNumber: +46 555-123456
|
||||
|
||||
dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person2
|
||||
userPassword: password
|
||||
cn: Some Person2
|
||||
sn: Person2
|
||||
description: Sweden, Company1, Some Person2
|
||||
telephoneNumber: +46 555-654321
|
||||
|
||||
dn: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person3
|
||||
userPassword: password
|
||||
cn: Some Person3
|
||||
sn: Person3
|
||||
description: Sweden, Company1, Some Person3
|
||||
telephoneNumber: +46 555-123654
|
||||
|
||||
dn: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.person4
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Sweden, Company2, Some Person
|
||||
telephoneNumber: +46 555-456321
|
||||
|
||||
dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=jayway,dc=se
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
objectclass: inetOrgPerson
|
||||
uid: some.norwegian
|
||||
userPassword: password
|
||||
cn: Some Person
|
||||
sn: Person
|
||||
description: Norway, Company1, Some Person+Person
|
||||
telephoneNumber: +45 555-654123
|
||||
Reference in New Issue
Block a user