LDAP-56: Specific configuration when running integration tests against Active Directory.
This commit is contained in:
@@ -88,3 +88,7 @@ idea {
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
systemProperties = System.properties
|
||||
}
|
||||
|
||||
|
||||
12
test/integration-tests/readme.itest.config.md
Normal file
12
test/integration-tests/readme.itest.config.md
Normal file
@@ -0,0 +1,12 @@
|
||||
## Spring LDAP Integration Test Configuration
|
||||
|
||||
By default, the Spring LDAP integration tests run against an in-process ApacheDS instance.
|
||||
To configure the tests to run against an external LDAP server, use the following system properties:
|
||||
|
||||
* `-Dspring.profiles.active=no-apacheds` (required to run against external LDAP server)
|
||||
* `-Durl=<ldap server url>` (defaults to ldap://127.0.0.1:389)
|
||||
* `-DuserDn=<ldap user dn>`
|
||||
* `-Dpassword=<ldap password>`
|
||||
* `-Dbase=<LDAP base DN>` - note that the base node MUST exist and that it will be completely cleared by the tests.
|
||||
* `-Dadtest` - A number of integration tests uses specific LDAP functionality which is not supported or very hard
|
||||
to configure for Active Directory. Use this flag to disable these tests.
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.itest;
|
||||
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public interface NoAdTest {
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class PersonWithDnAnnotations {
|
||||
@Transient
|
||||
private String company;
|
||||
|
||||
@DnAttribute(value="c", index=0)
|
||||
@DnAttribute(value="ou", index=0)
|
||||
@Transient
|
||||
private String country;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LdapAndJdbcDummyDaoImpl implements DummyDao {
|
||||
*/
|
||||
public void create(String country, String company, String fullname, String lastname, String description) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("c", country);
|
||||
dn.add("ou", country);
|
||||
dn.add("ou", company);
|
||||
dn.add("cn", fullname);
|
||||
|
||||
@@ -78,9 +78,8 @@ public class LdapAndJdbcDummyDaoImpl implements DummyDao {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastname);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
jdbcTemplate.update("update PERSON set lastname=?, description = ? where fullname = ?", new Object[] {
|
||||
lastname, description, fullname });
|
||||
}
|
||||
@@ -105,9 +104,8 @@ public class LdapAndJdbcDummyDaoImpl implements DummyDao {
|
||||
public void updateAndRename(String dn, String newDn, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
ldapTemplate.rename(dn, newDn);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class LdapDummyDaoImpl implements DummyDao {
|
||||
public void create(String country, String company, String fullname,
|
||||
String lastname, String description) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("c", country);
|
||||
dn.add("ou", country);
|
||||
dn.add("ou", company);
|
||||
dn.add("cn", fullname);
|
||||
|
||||
@@ -76,9 +76,8 @@ public class LdapDummyDaoImpl implements DummyDao {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastname);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -102,9 +101,8 @@ public class LdapDummyDaoImpl implements DummyDao {
|
||||
public void updateAndRename(String dn, String newDn, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
ldapTemplate.rename(dn, newDn);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
|
||||
public void create(OrgPerson person) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("c", person.getCountry());
|
||||
dn.add("ou", person.getCountry());
|
||||
dn.add("ou", person.getCompany());
|
||||
dn.add("cn", person.getFullname());
|
||||
|
||||
@@ -69,9 +69,8 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", person.getLastname());
|
||||
ctx.setAttributeValue("description", person.getDescription());
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
this.getHibernateTemplate().saveOrUpdate(person);
|
||||
|
||||
}
|
||||
@@ -85,9 +84,8 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", updatedDescription);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
ldapTemplate.rename(dn, newDn);
|
||||
|
||||
}
|
||||
@@ -104,7 +102,7 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
}
|
||||
|
||||
private String prepareDn(OrgPerson person){
|
||||
return "cn=" + person.getFullname() + ",ou=" + person.getCompany() + ",c=" + person.getCountry();
|
||||
return "cn=" + person.getFullname() + ",ou=" + person.getCompany() + ",ou=" + person.getCountry();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class AdSuite {
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.junit.experimental.categories.Categories;
|
||||
import org.junit.runner.manipulation.NoTestsRemainException;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
import org.springframework.ldap.itest.NoAdTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class LdapConditionallyFilteredTestRunner extends SpringJUnit4ClassRunner {
|
||||
/**
|
||||
* Constructs a new {@code SpringJUnit4ClassRunner} and initializes a
|
||||
* {@link org.springframework.test.context.TestContextManager} to provide Spring testing functionality to
|
||||
* standard JUnit tests.
|
||||
*
|
||||
* @param clazz the test class to be run
|
||||
* @see #createTestContextManager(Class)
|
||||
*/
|
||||
public LdapConditionallyFilteredTestRunner(Class<?> clazz) throws InitializationError {
|
||||
super(clazz);
|
||||
|
||||
String noadtest = System.getProperty("adtest");
|
||||
if (noadtest != null) {
|
||||
try {
|
||||
filter(new Categories.CategoryFilter(null, NoAdTest.class));
|
||||
} catch (NoTestsRemainException e) {
|
||||
// Nothing to do here.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,38 +16,63 @@
|
||||
|
||||
package org.springframework.ldap.itest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ldap.LdapConditionallyFilteredTestRunner;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NamingException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
|
||||
@DirtiesContext
|
||||
public abstract class AbstractLdapTemplateIntegrationTest extends AbstractJUnit4SpringContextTests {
|
||||
@RunWith(LdapConditionallyFilteredTestRunner.class)
|
||||
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })
|
||||
public abstract class AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private final static String DEFAULT_BASE = "dc=261consulting,dc=com";
|
||||
|
||||
@Autowired
|
||||
@Qualifier("contextSource")
|
||||
protected ContextSource contextSource;
|
||||
|
||||
@Value("${base}")
|
||||
protected String base;
|
||||
|
||||
@Value("${testRoot}")
|
||||
protected String testRoot;
|
||||
|
||||
@Before
|
||||
public void cleanAndSetup() throws NamingException, IOException {
|
||||
LdapTestUtils.cleanAndSetup(contextSource, getRoot(), getLdifFileResource());
|
||||
Resource ldifResource = getLdifFileResource();
|
||||
if(!LdapUtils.newLdapName(base).equals(LdapUtils.newLdapName(DEFAULT_BASE))) {
|
||||
List<String> lines = IOUtils.readLines(ldifResource.getInputStream());
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(sw);
|
||||
for (String line : lines) {
|
||||
writer.println(StringUtils.replace(line, DEFAULT_BASE, base));
|
||||
}
|
||||
|
||||
writer.flush();
|
||||
ldifResource = new ByteArrayResource(sw.toString().getBytes("UTF8"));
|
||||
}
|
||||
|
||||
LdapTestUtils.cleanAndSetup(contextSource, getRoot(), ldifResource);
|
||||
}
|
||||
|
||||
protected Resource getLdifFileResource() {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.ldap.itest;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
@@ -45,7 +46,7 @@ public class InvalidBackslashITest extends AbstractLdapTemplateIntegrationTest {
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static LdapName DN = LdapUtils.newLdapName("cn=Some\\\\Person6,ou=company1,c=Sweden");
|
||||
private static LdapName DN = LdapUtils.newLdapName("cn=Some\\\\Person6,ou=company1,ou=Sweden");
|
||||
|
||||
@Before
|
||||
public void prepareTestedInstance() throws Exception {
|
||||
@@ -69,10 +70,10 @@ public class InvalidBackslashITest extends AbstractLdapTemplateIntegrationTest {
|
||||
* including a backslach ('\') the Name supplied to DefaultDirObjectFactory
|
||||
* will be invalid.
|
||||
* <p>
|
||||
* E.g. the distinguished name "cn=Some\\Person6,ou=company1,c=Sweden"
|
||||
* E.g. the distinguished name "cn=Some\\Person6,ou=company1,ou=Sweden"
|
||||
* (indicating that the cn value is 'Some\Person'), will be represented by a
|
||||
* <code>CompositeName</code> with the string representation
|
||||
* "cn=Some\\\Person6,ou=company1,c=Sweden", which is in fact an invalid DN.
|
||||
* "cn=Some\\\Person6,ou=company1,ou=Sweden", which is in fact an invalid DN.
|
||||
* This will be supplied to <code>DistinguishedName</code> for parsing,
|
||||
* causing it to fail. This test makes sure that Spring LDAP properly works
|
||||
* around this bug.
|
||||
@@ -81,7 +82,7 @@ public class InvalidBackslashITest extends AbstractLdapTemplateIntegrationTest {
|
||||
* What happens under the covers is (in the Java LDAP Provider code):
|
||||
*
|
||||
* <pre>
|
||||
* LdapName ldapname = new LdapName("cn=Some\\\\Person6,ou=company1,c=Sweden");
|
||||
* LdapName ldapname = new LdapName("cn=Some\\\\Person6,ou=company1,ou=Sweden");
|
||||
* CompositeName compositeName = new CompositeName();
|
||||
* compositeName.add(ldapname.get(ldapname.size() - 1)); // for some odd reason
|
||||
* </pre>
|
||||
@@ -91,13 +92,14 @@ public class InvalidBackslashITest extends AbstractLdapTemplateIntegrationTest {
|
||||
* @throws InvalidNameException
|
||||
*/
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testSearchForDnSpoiledByCompositeName() throws InvalidNameException {
|
||||
List result = tested.search("", "(sn=Person6)", new AbstractContextMapper() {
|
||||
@Override
|
||||
protected Object doMapFromContext(DirContextOperations ctx) {
|
||||
LdapName dn = (LdapName) ctx.getDn();
|
||||
Rdn rdn = LdapUtils.getRdn(dn, "cn");
|
||||
assertEquals("cn=Some\\\\Person6,ou=company1,c=Sweden", dn.toString());
|
||||
assertEquals("cn=Some\\\\Person6,ou=company1,ou=Sweden", dn.toString());
|
||||
assertEquals("Some\\Person6", rdn.getValue());
|
||||
return new Object();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.Person;
|
||||
import org.springframework.ldap.itest.PersonAttributesMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.naming.NamingEnumeration;
|
||||
@@ -49,7 +47,7 @@ public class LdapTemplateAttributesMapperITest extends AbstractLdapTemplateInteg
|
||||
@Test
|
||||
public void testSearch_AttributeMapper() throws Exception {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
List result = tested.search("ou=company1,c=Sweden", "(&(objectclass=person)(sn=Person2))", mapper);
|
||||
List result = tested.search("ou=company1,ou=Sweden", "(&(objectclass=person)(sn=Person2))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
Person person = (Person) result.get(0);
|
||||
@@ -81,6 +79,6 @@ public class LdapTemplateAttributesMapperITest extends AbstractLdapTemplateInteg
|
||||
|
||||
assertEquals(1, result.size());
|
||||
|
||||
assertEquals(5, ((String[]) result.get(0)).length);
|
||||
assertEquals(4, ((String[]) result.get(0)).length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.ldap.itest;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.ldap.AuthenticationException;
|
||||
@@ -54,6 +55,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
private LdapTemplate tested;
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticate() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
@@ -61,6 +63,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithLdapQuery() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
@@ -71,6 +74,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithInvalidPassword() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
@@ -78,6 +82,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationException.class)
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithLdapQueryAndInvalidPassword() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
@@ -88,6 +93,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithLookupOperationPerformedOnAuthenticatedContext() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
@@ -106,6 +112,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithLdapQueryAndMapper() {
|
||||
DirContextOperations ctx = tested.authenticate(query()
|
||||
.where("objectclass").is("person")
|
||||
@@ -118,6 +125,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationException.class)
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithLdapQueryAndMapperAndInvalidPassword() {
|
||||
DirContextOperations ctx = tested.authenticate(query()
|
||||
.where("objectclass").is("person")
|
||||
@@ -127,6 +135,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithInvalidPasswordAndCollectedException() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
@@ -139,6 +148,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithFilterThatDoesNotMatchAnything() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(
|
||||
@@ -147,6 +157,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test(expected=IncorrectResultSizeDataAccessException.class)
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticateWithFilterThatMatchesSeveralEntries() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", "Some Person"));
|
||||
@@ -154,6 +165,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testLookupAttemptingCallback() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
|
||||
@@ -47,7 +47,7 @@ public class LdapTemplateBindUnbindITest extends
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String DN = "cn=Some Person4,ou=company1,c=Sweden";
|
||||
private static String DN = "cn=Some Person4,ou=company1,ou=Sweden";
|
||||
|
||||
@Test
|
||||
public void testBindAndUnbindWithAttributes() {
|
||||
@@ -64,7 +64,7 @@ public class LdapTemplateBindUnbindITest extends
|
||||
ctx.addAttributeValue("cn", "TEST");
|
||||
ctx.addAttributeValue("objectclass", "top");
|
||||
ctx.addAttributeValue("objectclass", "groupOfUniqueNames");
|
||||
ctx.addAttributeValue("uniqueMember", LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base));
|
||||
ctx.addAttributeValue("uniqueMember", LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base));
|
||||
tested.bind(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class LdapTemplateContextExecutorTest extends AbstractLdapTemplateIntegra
|
||||
public void testLookupLink() {
|
||||
ContextExecutor executor = new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws NamingException {
|
||||
return ctx.lookupLink("cn=Some Person,ou=company1,c=Sweden");
|
||||
return ctx.lookupLink("cn=Some Person,ou=company1,ou=Sweden");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.Person;
|
||||
import org.springframework.ldap.itest.PersonContextMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
@@ -48,7 +46,7 @@ public class LdapTemplateContextMapperITest extends AbstractLdapTemplateIntegrat
|
||||
@Test
|
||||
public void testSearch_ContextMapper() {
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
List result = tested.search("ou=company1,c=Sweden", "(&(objectclass=person)(sn=Person2))", mapper);
|
||||
List result = tested.search("ou=company1,ou=Sweden", "(&(objectclass=person)(sn=Person2))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
Person person = (Person) result.get(0);
|
||||
@@ -74,6 +72,6 @@ public class LdapTemplateContextMapperITest extends AbstractLdapTemplateIntegrat
|
||||
List result = tested.search("ou=groups", "(&(objectclass=groupOfUniqueNames)(cn=ROLE_USER))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(5, ((String[]) result.get(0)).length);
|
||||
assertEquals(4, ((String[]) result.get(0)).length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.support.CountNameClassPairCallbackHandler;
|
||||
import org.springframework.ldap.itest.PersonContextMapper;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.ldap.test.AttributeCheckContextMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.naming.ldap.LdapName;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
@@ -68,7 +68,7 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
public void testListBindings_ContextMapper() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.listBindings("ou=company2,c=Sweden" + BASE_STRING, contextMapper);
|
||||
List list = tested.listBindings("ou=company2,ou=Sweden" + BASE_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
@@ -76,14 +76,14 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
public void testListBindings_ContextMapper_Name() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
LdapName dn = LdapUtils.newLdapName("ou=company2,c=Sweden");
|
||||
LdapName dn = LdapUtils.newLdapName("ou=company2,ou=Sweden");
|
||||
List list = tested.listBindings(dn, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBindings_ContextMapper_MapToPersons() {
|
||||
LdapName dn = LdapUtils.newLdapName("ou=company1,c=Sweden");
|
||||
LdapName dn = LdapUtils.newLdapName("ou=company1,ou=Sweden");
|
||||
List list = tested.listBindings(dn, new PersonContextMapper());
|
||||
assertEquals(3, list.size());
|
||||
String personClass = "org.springframework.ldap.itest.Person";
|
||||
@@ -94,20 +94,28 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testList() {
|
||||
List list = tested.list(BASE_STRING);
|
||||
List<String> list = tested.list(BASE_STRING);
|
||||
assertEquals(3, list.size());
|
||||
assertTrue(list.contains("ou=groups"));
|
||||
assertTrue(list.contains("c=Norway"));
|
||||
assertTrue(list.contains("c=Sweden"));
|
||||
verifyBindings(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
private void verifyBindings(List<String> list) {
|
||||
LinkedList<LdapName> transformed = new LinkedList<LdapName>();
|
||||
|
||||
for (String s : list) {
|
||||
transformed.add(LdapUtils.newLdapName(s));
|
||||
}
|
||||
|
||||
assertTrue(transformed.contains(LdapUtils.newLdapName("ou=groups")));
|
||||
assertTrue(transformed.contains(LdapUtils.newLdapName("ou=Norway")));
|
||||
assertTrue(transformed.contains(LdapUtils.newLdapName("ou=Sweden")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testList_Name() {
|
||||
List list = tested.list(BASE_NAME);
|
||||
List<String> list = tested.list(BASE_NAME);
|
||||
assertEquals(3, list.size());
|
||||
assertTrue(list.contains("ou=groups"));
|
||||
assertTrue(list.contains("c=Norway"));
|
||||
assertTrue(list.contains("c=Sweden"));
|
||||
verifyBindings(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,11 +134,9 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testListBindings() {
|
||||
List list = tested.listBindings(BASE_STRING);
|
||||
List<String> list = tested.listBindings(BASE_STRING);
|
||||
assertEquals(3, list.size());
|
||||
assertTrue(list.contains("ou=groups"));
|
||||
assertTrue(list.contains("c=Norway"));
|
||||
assertTrue(list.contains("c=Sweden"));
|
||||
verifyBindings(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -51,7 +51,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
*/
|
||||
@Test
|
||||
public void testLookup_Plain() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person2, ou=company1,c=Sweden");
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden");
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
@@ -74,7 +74,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Test
|
||||
public void testLookup_AttributesMapper() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,c=Sweden", mapper);
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
@@ -84,7 +84,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Test
|
||||
public void testLookup_AttributesMapper_LdapName() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,c=Sweden"), mapper);
|
||||
Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"), mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
@@ -122,7 +122,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void testLookup_ReturnAttributes_AttributesMapper() {
|
||||
AttributesMapper mapper = new SubsetPersonAttributesMapper();
|
||||
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,c=Sweden", new String[] { "cn" }, mapper);
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
@@ -137,7 +137,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Test
|
||||
public void testLookup_ReturnAttributes_AttributesMapper_LdapName() {
|
||||
AttributesMapper mapper = new SubsetPersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,c=Sweden"),
|
||||
Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"),
|
||||
new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
@@ -153,7 +153,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Test
|
||||
public void testLookup_ContextMapper() {
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,c=Sweden", mapper);
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
@@ -168,56 +168,20 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void testLookup_ReturnAttributes_ContextMapper() {
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,c=Sweden", new String[] { "cn" }, mapper);
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that we can lookup an entry that has a multi-valued rdn, which
|
||||
* means more than one attribute is part of the relative DN for the entry.
|
||||
*/
|
||||
@Test
|
||||
public void DISABLED_testLookup_MultiValuedRdn() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person+sn=Person, ou=company1,c=Norway", mapper);
|
||||
|
||||
assertEquals("Some Person", person.getFullname());
|
||||
assertEquals("Person", person.getLastname());
|
||||
assertEquals("Norway, Company1, Some Person+Person", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that we can lookup an entry that has a multi-valued rdn, which
|
||||
* means more than one attribute is part of the relative DN for the entry.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void DISABLED_testLookup_MultiValuedRdn_DirContextAdapter() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person, ou=company1,c=Norway");
|
||||
|
||||
assertEquals("Some Person", result.getStringAttribute("cn"));
|
||||
assertEquals("Person", result.getStringAttribute("sn"));
|
||||
assertEquals("Norway, Company1, Some Person+Person", result.getStringAttribute("description"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLookup_GetNameInNamespace_Plain() {
|
||||
String expectedDn = "cn=Some Person2, ou=company1,c=Sweden";
|
||||
String expectedDn = "cn=Some Person2, ou=company1,ou=Sweden";
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(expectedDn);
|
||||
|
||||
LdapName expectedName = LdapUtils.newLdapName(expectedDn);
|
||||
assertEquals(expectedName, result.getDn());
|
||||
assertEquals("cn=Some Person2,ou=company1,c=Sweden," + base, result.getNameInNamespace());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLookup_GetNameInNamespace_MultiRdn() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person,ou=company1,c=Norway");
|
||||
|
||||
assertEquals("cn=Some Person+sn=Person,ou=company1,c=Norway", result.getDn().toString());
|
||||
assertEquals("cn=Some Person+sn=Person,ou=company1,c=Norway," + base, result.getNameInNamespace());
|
||||
assertEquals("cn=Some Person2,ou=company1,ou=Sweden," + base, result.getNameInNamespace());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.itest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
@ContextConfiguration(locations = {"/conf/ldapTemplateTestContext.xml"})
|
||||
public class LdapTemplateLookupMultiRdnITest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected Resource getLdifFileResource() {
|
||||
return new ClassPathResource("/setup_data_multi_rdn.ldif");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies that we can lookup an entry that has a multi-valued rdn, which
|
||||
* means more than one attribute is part of the relative DN for the entry.
|
||||
*/
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testLookup_MultiValuedRdn() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway", mapper);
|
||||
|
||||
assertEquals("Some Person", person.getFullname());
|
||||
assertEquals("Person", person.getLastname());
|
||||
assertEquals("Norway, Company1, Some Person+Person", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that we can lookup an entry that has a multi-valued rdn, which
|
||||
* means more than one attribute is part of the relative DN for the entry.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testLookup_MultiValuedRdn_DirContextAdapter() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway");
|
||||
|
||||
assertEquals("Some Person", result.getStringAttribute("cn"));
|
||||
assertEquals("Person", result.getStringAttribute("sn"));
|
||||
assertEquals("Norway, Company1, Some Person+Person", result.getStringAttribute("description"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testLookup_GetNameInNamespace_MultiRdn() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person,ou=company1,ou=Norway");
|
||||
|
||||
assertEquals("cn=Some Person+sn=Person,ou=company1,ou=Norway", result.getDn().toString());
|
||||
assertEquals("cn=Some Person+sn=Person,ou=company1,ou=Norway," + base, result.getNameInNamespace());
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
@@ -56,9 +58,9 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String PERSON4_DN = "cn=Some Person4,ou=company1,c=Sweden";
|
||||
private static String PERSON4_DN = "cn=Some Person4,ou=company1,ou=Sweden";
|
||||
|
||||
private static String PERSON5_DN = "cn=Some Person5,ou=company1,c=Sweden";
|
||||
private static String PERSON5_DN = "cn=Some Person5,ou=company1,ou=Sweden";
|
||||
|
||||
@Before
|
||||
public void prepareTestedInstance() throws Exception {
|
||||
@@ -114,10 +116,10 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(2, attributes.length);
|
||||
assertEquals("Some other description", attributes[0]);
|
||||
assertEquals("Another description", attributes[1]);
|
||||
List<String> attributes = Arrays.asList(result.getStringAttributes("description"));
|
||||
assertEquals(2, attributes.size());
|
||||
assertTrue(attributes.contains("Some other description"));
|
||||
assertTrue(attributes.contains("Another description"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,17 +132,17 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(3, attributes.length);
|
||||
assertEquals("Some description", attributes[0]);
|
||||
assertEquals("Some other description", attributes[1]);
|
||||
assertEquals("Another description", attributes[2]);
|
||||
List<String> attributes = Arrays.asList(result.getStringAttributes("description"));
|
||||
assertEquals(3, attributes.size());
|
||||
assertTrue(attributes.contains("Some other description"));
|
||||
assertTrue(attributes.contains("Another description"));
|
||||
assertTrue(attributes.contains("Some description"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes_AddAttributeValueWithExistingValue() {
|
||||
DirContextOperations ctx = tested.lookupContext("cn=ROLE_USER,ou=groups");
|
||||
ctx.addAttributeValue("uniqueMember", "cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se");
|
||||
ctx.addAttributeValue("uniqueMember", "cn=Some Person,ou=company1,ou=Norway," + base);
|
||||
tested.modifyAttributes(ctx);
|
||||
assertTrue(true);
|
||||
}
|
||||
@@ -177,11 +179,11 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(3, attributes.length);
|
||||
assertEquals("Some description", attributes[0]);
|
||||
assertEquals("Some other description", attributes[1]);
|
||||
assertEquals("Another description", attributes[2]);
|
||||
List<String> attributes = Arrays.asList(result.getStringAttributes("description"));
|
||||
assertEquals(3, attributes.size());
|
||||
assertTrue(attributes.contains("Some other description"));
|
||||
assertTrue(attributes.contains("Another description"));
|
||||
assertTrue(attributes.contains("Some description"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -213,12 +215,12 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
// Verify
|
||||
adapter = (DirContextAdapter) tested.lookup(PERSON5_DN);
|
||||
String[] attributes = adapter.getStringAttributes("description");
|
||||
assertEquals(4, attributes.length);
|
||||
assertEquals("qwe", attributes[0]);
|
||||
assertEquals("123", attributes[1]);
|
||||
assertEquals("klytt", attributes[2]);
|
||||
assertEquals("kalle", attributes[3]);
|
||||
List<String> attributes = Arrays.asList(adapter.getStringAttributes("description"));
|
||||
assertEquals(4, attributes.size());
|
||||
assertTrue(attributes.contains("qwe"));
|
||||
assertTrue(attributes.contains("123"));
|
||||
assertTrue(attributes.contains("klytt"));
|
||||
assertTrue(attributes.contains("kalle"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +244,7 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void verifyCompleteReplacementOfUniqueMemberAttribute_Ldap119Workaround() {
|
||||
DirContextOperations ctx = tested.lookupContext("cn=ROLE_USER,ou=groups");
|
||||
ctx.setAttributeValues("uniqueMember",
|
||||
new String[]{"cn=Some Person4,ou=company1,c=Sweden,dc=jayway,dc=se"},
|
||||
new String[]{"cn=Some Person,ou=company1,ou=Norway," + base},
|
||||
true);
|
||||
ctx.getModificationItems();
|
||||
|
||||
@@ -257,7 +259,7 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void verifyCompleteReplacementOfUniqueMemberAttribute_Ldap119() {
|
||||
DirContextOperations ctx = tested.lookupContext("cn=ROLE_USER,ou=groups");
|
||||
ctx.setAttributeValues("uniqueMember",
|
||||
new String[]{"cn=Some Person4,ou=company1,c=Sweden,dc=jayway,dc=se"});
|
||||
new String[]{"cn=Some Person,ou=company1,ou=Norway," + base});
|
||||
ctx.getModificationItems();
|
||||
|
||||
tested.modifyAttributes(ctx);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class LdapTemplateNoBaseSuffixITest extends AbstractLdapTemplateIntegrati
|
||||
*/
|
||||
@Test
|
||||
public void testLookup_Plain() {
|
||||
String expectedDn = "cn=Some Person2, ou=company1, c=Sweden," + base;
|
||||
String expectedDn = "cn=Some Person2, ou=company1, ou=Sweden," + base;
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(expectedDn);
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
@@ -83,18 +83,18 @@ public class LdapTemplateNoBaseSuffixITest extends AbstractLdapTemplateIntegrati
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
|
||||
adapter.setAttributeValue("cn", "Some Person4");
|
||||
adapter.setAttributeValue("sn", "Person4");
|
||||
tested.bind("cn=Some Person4, ou=company1, c=Sweden," + base, adapter, null);
|
||||
tested.bind("cn=Some Person4, ou=company1, ou=Sweden," + base, adapter, null);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person4, ou=company1, c=Sweden," + base);
|
||||
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
|
||||
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertEquals(LdapUtils.newLdapName("cn=Some Person4,ou=company1,c=Sweden," + base), result.getDn());
|
||||
assertEquals(LdapUtils.newLdapName("cn=Some Person4,ou=company1,ou=Sweden," + base), result.getDn());
|
||||
|
||||
tested.unbind("cn=Some Person4,ou=company1,c=Sweden," + base);
|
||||
tested.unbind("cn=Some Person4,ou=company1,ou=Sweden," + base);
|
||||
try {
|
||||
tested.lookup("cn=Some Person4, ou=company1, c=Sweden," + base);
|
||||
tested.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
|
||||
@@ -60,20 +60,20 @@ public class LdapTemplatePooledITest extends AbstractJUnit4SpringContextTests {
|
||||
*/
|
||||
@Test
|
||||
public void verifyThatInvalidConnectionIsAutomaticallyPurged() throws Exception {
|
||||
LdapTestUtils.startEmbeddedServer(1888, base, "jayway");
|
||||
LdapTestUtils.startEmbeddedServer(1888, "dc=261consulting,dc=com", "jayway");
|
||||
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.emptyLdapName(), new ClassPathResource("/setup_data.ldif"));
|
||||
|
||||
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
|
||||
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,ou=Sweden");
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
|
||||
// Shutdown server and kill all existing connections
|
||||
LdapTestUtils.shutdownEmbeddedServer();
|
||||
LdapTestUtils.startEmbeddedServer(1888, base, "jayway");
|
||||
LdapTestUtils.startEmbeddedServer(1888, "dc=261consulting,dc=com", "jayway");
|
||||
|
||||
try {
|
||||
tested.lookup("cn=Some Person2, ou=company1,c=Sweden");
|
||||
tested.lookup("cn=Some Person2, ou=company1,ou=Sweden");
|
||||
fail("Exception expected");
|
||||
} catch (Exception expected) {
|
||||
// This should fail because the target connection was closed
|
||||
@@ -82,6 +82,6 @@ public class LdapTemplatePooledITest extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.emptyLdapName(), new ClassPathResource("/setup_data.ldif"));
|
||||
// But this should be OK, because the dirty connection should have been automatically purged.
|
||||
tested.lookup("cn=Some Person2, ou=company1,c=Sweden");
|
||||
tested.lookup("cn=Some Person2, ou=company1,ou=Sweden");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.ldap.itest;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
@@ -44,7 +45,7 @@ public class LdapTemplateRecursiveDeleteITest extends AbstractLdapTemplateIntegr
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static LdapName DN = LdapUtils.newLdapName("cn=Some Person5,ou=company1,c=Sweden");
|
||||
private static LdapName DN = LdapUtils.newLdapName("cn=Some Person5,ou=company1,ou=Sweden");
|
||||
|
||||
private LdapName firstSubDn;
|
||||
|
||||
@@ -102,6 +103,7 @@ public class LdapTemplateRecursiveDeleteITest extends AbstractLdapTemplateIntegr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testRecursiveUnbind() {
|
||||
tested.unbind(DN, true);
|
||||
|
||||
@@ -112,6 +114,7 @@ public class LdapTemplateRecursiveDeleteITest extends AbstractLdapTemplateIntegr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testRecursiveUnbindOnLeaf() {
|
||||
tested.unbind(leafDn, true);
|
||||
verifyDeleted(leafDn);
|
||||
|
||||
@@ -45,9 +45,9 @@ public class LdapTemplateRenameITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Autowired
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String DN = "cn=Some Person6,ou=company1,c=Sweden";
|
||||
private static String DN = "cn=Some Person6,ou=company1,ou=Sweden";
|
||||
|
||||
private static String NEWDN = "cn=Some Person6,ou=company2,c=Sweden";
|
||||
private static String NEWDN = "cn=Some Person6,ou=company2,ou=Sweden";
|
||||
|
||||
@Before
|
||||
public void prepareTestedInstance() throws Exception {
|
||||
|
||||
@@ -140,7 +140,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.search(query()
|
||||
.base("ou=company1,c=Sweden")
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
@@ -164,7 +164,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.search(query()
|
||||
.base("c=Norway")
|
||||
.base("ou=Norway")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(0, list.size());
|
||||
@@ -314,7 +314,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.search(query()
|
||||
.base("ou=company1,c=Sweden")
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
@@ -342,7 +342,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
DirContextOperations result =
|
||||
tested.searchForContext(query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,c=Sweden")
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.search(query()
|
||||
.base("ou=company1,c=Sweden")
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
@@ -164,7 +164,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.search(query()
|
||||
.base("c=Norway")
|
||||
.base("ou=Norway")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(0, list.size());
|
||||
@@ -314,7 +314,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.search(query()
|
||||
.base("ou=company1,c=Sweden")
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
@@ -342,7 +342,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
DirContextOperations result =
|
||||
tested.searchForContext(query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,c=Sweden")
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
package org.springframework.ldap.itest.control;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.itest.NoAdTest;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@@ -50,6 +52,7 @@ public class SupportedControlsITest extends AbstractLdapTemplateIntegrationTest
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testExpectedControlsSupported() throws Exception {
|
||||
/**
|
||||
* Maps the 'supportedcontrol' attribute to a string array.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.ldap.itest.core.simple;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
@@ -26,6 +27,7 @@ import org.springframework.ldap.core.simple.SimpleLdapTemplate;
|
||||
import org.springframework.ldap.filter.AndFilter;
|
||||
import org.springframework.ldap.filter.EqualsFilter;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.itest.NoAdTest;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@@ -41,22 +43,22 @@ import static junit.framework.Assert.fail;
|
||||
|
||||
@ContextConfiguration(locations = {"/conf/simpleLdapTemplateTestContext.xml"})
|
||||
public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest {
|
||||
private static String DN_STRING = "cn=Some Person4,ou=company1,c=Sweden";
|
||||
private static String DN_STRING = "cn=Some Person4,ou=company1,ou=Sweden";
|
||||
|
||||
private static LdapName DN = LdapUtils.newLdapName("cn=Some Person4,ou=company1,c=Sweden");
|
||||
private static LdapName DN = LdapUtils.newLdapName("cn=Some Person4,ou=company1,ou=Sweden");
|
||||
|
||||
@Autowired
|
||||
private SimpleLdapTemplate ldapTemplate;
|
||||
|
||||
@Test
|
||||
public void testLookup() {
|
||||
String result = ldapTemplate.lookup("cn=Some Person,ou=company1,c=Sweden", new CnContextMapper());
|
||||
String result = ldapTemplate.lookup("cn=Some Person,ou=company1,ou=Sweden", new CnContextMapper());
|
||||
assertEquals("Some Person", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLookupName() {
|
||||
String result = ldapTemplate.lookup(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden"),
|
||||
String result = ldapTemplate.lookup(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden"),
|
||||
new CnContextMapper());
|
||||
assertEquals("Some Person", result);
|
||||
}
|
||||
@@ -116,7 +118,7 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
DirContextOperations ctx = ldapTemplate.lookupContext("cn=Some Person,ou=company1,c=Sweden");
|
||||
DirContextOperations ctx = ldapTemplate.lookupContext("cn=Some Person,ou=company1,ou=Sweden");
|
||||
|
||||
ctx.setAttributeValue("description", "updated description");
|
||||
ctx.setAttributeValue("telephoneNumber", "0000001");
|
||||
@@ -124,7 +126,7 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
|
||||
// verify that the data was properly updated.
|
||||
ldapTemplate.lookup("cn=Some Person,ou=company1,c=Sweden", new ParameterizedContextMapper<Object>() {
|
||||
ldapTemplate.lookup("cn=Some Person,ou=company1,ou=Sweden", new ParameterizedContextMapper<Object>() {
|
||||
public Object mapFromContext(Object ctx) {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
assertEquals("updated description", adapter.getStringAttribute("description"));
|
||||
@@ -137,7 +139,7 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Test
|
||||
public void testModifyAttributesName() {
|
||||
DirContextOperations ctx = ldapTemplate.lookupContext(LdapUtils.newLdapName(
|
||||
"cn=Some Person,ou=company1,c=Sweden"));
|
||||
"cn=Some Person,ou=company1,ou=Sweden"));
|
||||
|
||||
ctx.setAttributeValue("description", "updated description");
|
||||
ctx.setAttributeValue("telephoneNumber", "0000001");
|
||||
@@ -145,7 +147,7 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
|
||||
// verify that the data was properly updated.
|
||||
ldapTemplate.lookup("cn=Some Person,ou=company1,c=Sweden", new ParameterizedContextMapper<Object>() {
|
||||
ldapTemplate.lookup("cn=Some Person,ou=company1,ou=Sweden", new ParameterizedContextMapper<Object>() {
|
||||
public Object mapFromContext(Object ctx) {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
assertEquals("updated description", adapter.getStringAttribute("description"));
|
||||
@@ -195,6 +197,7 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testAuthenticate() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.ldap.itest.core.support;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
@@ -27,7 +28,7 @@ import org.springframework.ldap.core.simple.AbstractParameterizedContextMapper;
|
||||
import org.springframework.ldap.core.support.LdapContextSource;
|
||||
import org.springframework.ldap.filter.EqualsFilter;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.repository.Query;
|
||||
import org.springframework.ldap.itest.NoAdTest;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@@ -110,10 +111,11 @@ public class LdapContextSourceIntegrationTest extends AbstractLdapTemplateIntegr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void testGetContext() throws NamingException {
|
||||
DirContext ctx = null;
|
||||
try {
|
||||
String expectedPrincipal = "cn=Some Person,ou=company1,c=Sweden," + base;
|
||||
String expectedPrincipal = "cn=Some Person,ou=company1,ou=Sweden," + base;
|
||||
String expectedCredentials = "password";
|
||||
ctx = tested.getContext(expectedPrincipal, expectedCredentials);
|
||||
assertNotNull(ctx);
|
||||
@@ -139,6 +141,7 @@ public class LdapContextSourceIntegrationTest extends AbstractLdapTemplateIntegr
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
@Category(NoAdTest.class)
|
||||
public void verifyAuthenticate() {
|
||||
EqualsFilter filter = new EqualsFilter("cn", "Some Person2");
|
||||
List<String> results = ldapTemplate.search("", filter.toString(), new DnContextMapper());
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -120,7 +120,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
Object dbResult = jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'",
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
@@ -130,12 +130,12 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(dbResult);
|
||||
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
|
||||
fail("DummyException expected");
|
||||
@@ -169,7 +169,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -197,8 +197,8 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
@@ -229,8 +229,8 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
@@ -248,7 +248,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
@@ -272,7 +272,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
@@ -291,7 +291,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.unbindWithException(dn, "Some Person");
|
||||
@@ -323,7 +323,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -122,7 +122,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
Object dbResult = jdbcTemplate.queryForObject("select * from PERSON where fullname='some testperson'",
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
@@ -132,12 +132,12 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(dbResult);
|
||||
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
|
||||
fail("DummyException expected");
|
||||
@@ -171,7 +171,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -199,8 +199,8 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
@@ -231,8 +231,8 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
@@ -250,7 +250,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
@@ -274,7 +274,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
@@ -293,7 +293,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.unbindWithException(dn, "Some Person");
|
||||
@@ -325,7 +325,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -89,7 +89,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
String expectedDn = "cn=some testperson, ou=company1, c=Sweden";
|
||||
String expectedDn = "cn=some testperson, ou=company1, ou=Sweden";
|
||||
Object ldapResult = ldapTemplate.lookup(expectedDn);
|
||||
assertNotNull(ldapResult);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
|
||||
fail("DummyException expected");
|
||||
@@ -122,7 +122,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -141,8 +141,8 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
@@ -173,8 +173,8 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
@@ -192,7 +192,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
@@ -216,7 +216,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
@@ -234,7 +234,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.unbindWithException(dn, "Some Person");
|
||||
@@ -257,7 +257,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -90,7 +90,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
String expectedDn = "cn=some testperson, ou=company1, c=Sweden";
|
||||
String expectedDn = "cn=some testperson, ou=company1, ou=Sweden";
|
||||
Object ldapResult = ldapTemplate.lookup(expectedDn);
|
||||
assertNotNull(ldapResult);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
dummyDao.updateWithException(dn, "Some Person", "Updated Person", "Updated description");
|
||||
fail("DummyException expected");
|
||||
@@ -123,7 +123,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
dummyDao.update(dn, "Some Person", "Updated Person", "Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -142,8 +142,8 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.updateAndRenameWithException(dn, newDn, "Updated description");
|
||||
@@ -174,8 +174,8 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
@@ -217,7 +217,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
@@ -235,7 +235,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.unbindWithException(dn, "Some Person");
|
||||
@@ -258,7 +258,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ public class ContextSourceTransactionManagerSubtreeIntegrationTest extends Abstr
|
||||
|
||||
@Test
|
||||
public void testLdap168DeleteRecursively() {
|
||||
dummyDao.deleteRecursively("ou=company1,c=Sweden");
|
||||
dummyDao.deleteRecursively("ou=company1,ou=Sweden");
|
||||
|
||||
try {
|
||||
ldapTemplate.lookup("ou=company1,c=Sweden");
|
||||
ldapTemplate.lookup("ou=company1,ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
@@ -75,14 +75,14 @@ public class ContextSourceTransactionManagerSubtreeIntegrationTest extends Abstr
|
||||
@Test
|
||||
public void testLdap168DeleteWithException() {
|
||||
try {
|
||||
dummyDao.deleteRecursivelyWithException("ou=company1,c=Sweden");
|
||||
dummyDao.deleteRecursivelyWithException("ou=company1,ou=Sweden");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Entry should have been restored
|
||||
ldapTemplate.lookup("ou=company1,c=Sweden");
|
||||
ldapTemplate.lookup("ou=company1,ou=Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -130,7 +130,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
// Verify that no entry was created in ldap or hibernate db
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -159,7 +159,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
this.dummyDao.create(person);
|
||||
person = null;
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, new Integer(2));
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(fromDb);
|
||||
@@ -167,7 +167,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson originalPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
originalPerson.setLastname("fooo");
|
||||
try {
|
||||
@@ -198,7 +198,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
@@ -222,8 +222,8 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
@@ -258,8 +258,8 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
@@ -276,7 +276,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
@@ -300,7 +300,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
@@ -318,7 +318,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
|
||||
try {
|
||||
@@ -353,7 +353,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
dummyDao.unbind(person);
|
||||
|
||||
@@ -130,7 +130,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
// Verify that no entry was created in ldap or hibernate db
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -159,7 +159,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
this.dummyDao.create(person);
|
||||
person = null;
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, new Integer(2));
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(fromDb);
|
||||
@@ -167,7 +167,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson originalPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
originalPerson.setLastname("fooo");
|
||||
try {
|
||||
@@ -198,7 +198,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
@@ -222,8 +222,8 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
person.setLastname("Updated Person");
|
||||
person.setDescription("Updated description");
|
||||
@@ -258,8 +258,8 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
String dn = "cn=Some Person2,ou=company1,ou=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
@@ -276,7 +276,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname", "Updated description");
|
||||
@@ -300,7 +300,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
dummyDao.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
@@ -318,7 +318,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
|
||||
try {
|
||||
@@ -353,7 +353,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
|
||||
@Test
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
String dn = "cn=Some Person,ou=company1,ou=Sweden";
|
||||
// Perform test
|
||||
OrgPerson person = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
dummyDao.unbind(person);
|
||||
|
||||
@@ -47,84 +47,83 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
|
||||
assertNotNull(group);
|
||||
assertEquals("ROLE_USER", group.getName());
|
||||
assertEquals(5, group.getMembers().size());
|
||||
assertEquals(4, group.getMembers().size());
|
||||
|
||||
Set<Name> members = group.getMembers();
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,c=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Norway," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company2,c=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person3,ou=company1,c=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company2,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden," + base)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveMember() {
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
group.removeMember(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base));
|
||||
group.removeMember(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base));
|
||||
tested.update(group);
|
||||
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(4, members.size());
|
||||
assertFalse(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base)));
|
||||
assertEquals(3, members.size());
|
||||
assertFalse(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveMemberSyntacticallyEqual() {
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
group.removeMember(LdapUtils.newLdapName("cn=Some Person,OU=company1, C=Sweden," + base));
|
||||
group.removeMember(LdapUtils.newLdapName("cn=Some Person,OU=company1, ou=Sweden," + base));
|
||||
tested.update(group);
|
||||
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(4, members.size());
|
||||
assertFalse(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base)));
|
||||
assertEquals(3, members.size());
|
||||
assertFalse(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddMember() {
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
group.addMember(LdapUtils.newLdapName("cn=Some Person+sn=Person,ou=company1,c=Norway," + base));
|
||||
group.addMember(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Norway," + base));
|
||||
tested.update(group);
|
||||
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(6, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person+sn=Person,ou=company1,c=Norway," + base)));
|
||||
assertEquals(5, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Norway," + base)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddMemberDuplicate() {
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
group.addMember(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base));
|
||||
group.addMember(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base));
|
||||
tested.update(group);
|
||||
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(5, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base)));
|
||||
assertEquals(4, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddMemberSyntacticallyEqualDuplicate() {
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
group.addMember(LdapUtils.newLdapName("cn=Some Person,OU=company1 ,C=Sweden," + base));
|
||||
group.addMember(LdapUtils.newLdapName("cn=Some Person,OU=company1 ,ou=Sweden," + base));
|
||||
tested.update(group);
|
||||
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(5, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base)));
|
||||
assertEquals(4, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,8 +131,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
group.setMembers(new HashSet<Name>(){{
|
||||
add(LdapUtils.newLdapName("CN=Some Person,OU=company1, C=Sweden, " + base));
|
||||
add(LdapUtils.newLdapName("CN=Some Person2, OU=company1,C=Sweden," + base));
|
||||
add(LdapUtils.newLdapName("CN=Some Person,OU=company1, ou=Sweden, " + base));
|
||||
add(LdapUtils.newLdapName("CN=Some Person2, OU=company1,ou=Sweden," + base));
|
||||
}});
|
||||
tested.update(group);
|
||||
|
||||
@@ -142,7 +141,7 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Set<Name> members = verification.getMembers();
|
||||
|
||||
assertEquals(2, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,c=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,c=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,ou=Sweden," + base)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
|
||||
@Test
|
||||
public void testFindByDn() {
|
||||
PersonWithDnAnnotations person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,c=Sweden"),
|
||||
PersonWithDnAnnotations person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertNotNull(person);
|
||||
@@ -74,7 +74,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
@Test
|
||||
public void testFindInCountry() {
|
||||
List<PersonWithDnAnnotations> persons = tested.find(query()
|
||||
.base("c=Sweden")
|
||||
.base("ou=Sweden")
|
||||
.where("cn").isPresent(), PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals(4, persons.size());
|
||||
@@ -114,7 +114,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
|
||||
assertEquals(6, tested.findAll(PersonWithDnAnnotations.class).size());
|
||||
|
||||
person = tested.findByDn(LdapUtils.newLdapName("cn=New Person,ou=company1,c=Sweden"),
|
||||
person = tested.findByDn(LdapUtils.newLdapName("cn=New Person,ou=company1,ou=Sweden"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals("New Person", person.getCommonName());
|
||||
@@ -136,7 +136,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
tested.update(person);
|
||||
|
||||
person = tested.findByDn(
|
||||
LdapUtils.newLdapName("cn=Some Person3, ou=company1, c=Sweden"),
|
||||
LdapUtils.newLdapName("cn=Some Person3, ou=company1, ou=Sweden"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
@@ -155,7 +155,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
tested.update(person);
|
||||
|
||||
person = tested.findByDn(
|
||||
LdapUtils.newLdapName("cn=Some Person3, ou=company1, c=Norway"),
|
||||
LdapUtils.newLdapName("cn=Some Person3, ou=company1, ou=Norway"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
|
||||
@@ -58,7 +58,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
|
||||
@Test
|
||||
public void testFindByDn() {
|
||||
Person person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,c=Sweden"), Person.class);
|
||||
Person person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), Person.class);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
@@ -69,7 +69,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
|
||||
@Test(expected = OdmException.class)
|
||||
public void testFindByDnThrowsExceptionOnInvalidEntry() {
|
||||
tested.findByDn(LdapUtils.newLdapName("ou=company1,c=Sweden"), Person.class);
|
||||
tested.findByDn(LdapUtils.newLdapName("ou=company1,ou=Sweden"), Person.class);
|
||||
}
|
||||
|
||||
@Test(expected = EmptyResultDataAccessException.class)
|
||||
@@ -96,7 +96,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
@Test
|
||||
public void testFindInCountry() {
|
||||
List<Person> persons = tested.find(query()
|
||||
.base("c=Sweden")
|
||||
.base("ou=Sweden")
|
||||
.where("cn").isPresent(), Person.class);
|
||||
|
||||
assertEquals(4, persons.size());
|
||||
@@ -114,7 +114,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
@Test
|
||||
public void testCreate() {
|
||||
Person person = new Person();
|
||||
person.setDn(LdapNameBuilder.newLdapName("ou=company1,c=Sweden")
|
||||
person.setDn(LdapNameBuilder.newLdapName("ou=company1,ou=Sweden")
|
||||
.add("cn", "New Person").build());
|
||||
person.setCommonName("New Person");
|
||||
person.setSurname("Person");
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
@ContextConfiguration(locations = {"/conf/repositoryScanAnnotationTestContext.xml"})
|
||||
public class RepositoryScanAnnotationConfiguredITest extends AbstractLdapTemplateIntegrationTest {
|
||||
private static final Name PERSON3_DN = LdapUtils.newLdapName("cn=Some Person3, ou=Company1, c=Sweden");
|
||||
private static final Name PERSON3_DN = LdapUtils.newLdapName("cn=Some Person3, ou=Company1, ou=Sweden");
|
||||
|
||||
@Autowired
|
||||
private PersonRepository tested;
|
||||
|
||||
@@ -46,8 +46,8 @@ import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
*/
|
||||
@ContextConfiguration(locations = {"/conf/repositoryScanTestContext.xml"})
|
||||
public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
private static final Name PERSON1_DN = LdapUtils.newLdapName("cn=Some Person, ou=Company1, c=Sweden");
|
||||
private static final Name PERSON3_DN = LdapUtils.newLdapName("cn=Some Person3, ou=Company1, c=Sweden");
|
||||
private static final Name PERSON1_DN = LdapUtils.newLdapName("cn=Some Person, ou=Company1, ou=Sweden");
|
||||
private static final Name PERSON3_DN = LdapUtils.newLdapName("cn=Some Person3, ou=Company1, ou=Sweden");
|
||||
|
||||
@Autowired
|
||||
private PersonRepository tested;
|
||||
@@ -173,7 +173,7 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
@Test
|
||||
public void testCreate() {
|
||||
Person person = new Person();
|
||||
LdapName dn = LdapNameBuilder.newLdapName("ou=company1,c=Sweden")
|
||||
LdapName dn = LdapNameBuilder.newLdapName("ou=company1,ou=Sweden")
|
||||
.add("cn", "New Person").build();
|
||||
person.setDn(dn);
|
||||
person.setCommonName("New Person");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<property name="urls" value="${url}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="base" value="dc=261consulting,dc=com" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
@@ -20,7 +20,7 @@
|
||||
<property name="urls" value="${url}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="cn=john doe, ${base}" />
|
||||
<property name="base" value="cn=john doe, dc=261consulting,dc=com" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<property name="urls" value="${url}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="base" value="dc=261consulting,dc=com" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
@@ -20,7 +20,7 @@
|
||||
<property name="urls" value="${url}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="base" value="dc=261consulting,dc=com" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<property name="urls" value="${url}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="base" value="dc=261consulting,dc=com" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<property name="urls" value="${url}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="base" value="dc=261consulting,dc=com" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</beans>
|
||||
|
||||
<beans profile="no-apacheds">
|
||||
<ldap:context-source url="ldap://localhost:389"
|
||||
<ldap:context-source url="${url}"
|
||||
base="${base}"
|
||||
username="${userDn}"
|
||||
password="${password}"/>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</beans>
|
||||
|
||||
<beans profile="no-apacheds">
|
||||
<ldap:context-source url="ldap://localhost:389"
|
||||
<ldap:context-source url="${url}"
|
||||
username="${userDn}"
|
||||
password="${password}"/>
|
||||
</beans>
|
||||
|
||||
@@ -3,53 +3,35 @@ objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: groups
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=261consulting,dc=com
|
||||
dn: ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
objectclass: organizationalUnit
|
||||
ou: Sweden
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=261consulting,dc=com
|
||||
dn: ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
objectclass: organizationalUnit
|
||||
ou: Norway
|
||||
|
||||
dn: c=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Sweden
|
||||
description: The country of Sweden
|
||||
|
||||
dn: c=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Norway
|
||||
description: The country of Norway
|
||||
|
||||
dn: ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: ou=company2,c=Sweden,dc=261consulting,dc=com
|
||||
dn: ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company2
|
||||
description: Second company in Sweden
|
||||
|
||||
dn: ou=company1,c=Norway,dc=261consulting,dc=com
|
||||
dn: ou=company1,ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Norway
|
||||
|
||||
dn: cn=Some Person,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -61,7 +43,7 @@ sn: Person
|
||||
description: Sweden, Company1, Some Person
|
||||
telephoneNumber: +46 555-123456
|
||||
|
||||
dn: cn=Some Person2,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -73,7 +55,7 @@ sn: Person2
|
||||
description: Sweden, Company1, Some Person2
|
||||
telephoneNumber: +46 555-654321
|
||||
|
||||
dn: cn=Some Person3,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person3,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -85,7 +67,7 @@ sn: Person3
|
||||
description: Sweden, Company1, Some Person3
|
||||
telephoneNumber: +46 555-123654
|
||||
|
||||
dn: cn=Some Person,ou=company2,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person,ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -97,7 +79,7 @@ sn: Person
|
||||
description: Sweden, Company2, Some Person
|
||||
telephoneNumber: +46 555-456321
|
||||
|
||||
dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=261consulting,dc=com
|
||||
dn: cn=Some Person,ou=company1,ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -108,3 +90,18 @@ cn: Some Person
|
||||
sn: Person
|
||||
description: Norway, Company1, Some Person+Person
|
||||
telephoneNumber: +45 555-654123
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person3,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
dn: ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: groups
|
||||
|
||||
dn: ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: Sweden
|
||||
|
||||
dn: ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: Norway
|
||||
|
||||
dn: ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company2
|
||||
description: Second company in Sweden
|
||||
|
||||
dn: ou=company1,ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Norway
|
||||
|
||||
dn: cn=Some Person,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
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,ou=Sweden,dc=261consulting,dc=com
|
||||
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,ou=Sweden,dc=261consulting,dc=com
|
||||
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,ou=Sweden,dc=261consulting,dc=com
|
||||
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,ou=Norway,dc=261consulting,dc=com
|
||||
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
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person3,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
@@ -3,59 +3,41 @@ objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: groups
|
||||
|
||||
dn: cn=ROLE_USER,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
|
||||
dn: ou=temp,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: temp
|
||||
description: temp entry renaming node
|
||||
|
||||
dn: c=Sweden,dc=261consulting,dc=com
|
||||
dn: ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Sweden
|
||||
description: The country of Sweden
|
||||
objectclass: organizationalUnit
|
||||
ou: Sweden
|
||||
|
||||
dn: c=Norway,dc=261consulting,dc=com
|
||||
dn: ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: country
|
||||
c: Norway
|
||||
description: The country of Norway
|
||||
objectclass: organizationalUnit
|
||||
ou: Norway
|
||||
|
||||
dn: ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Sweden
|
||||
|
||||
dn: ou=company2,c=Sweden,dc=261consulting,dc=com
|
||||
dn: ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company2
|
||||
description: Second company in Sweden
|
||||
|
||||
dn: ou=company1,c=Norway,dc=261consulting,dc=com
|
||||
dn: ou=company1,ou=Norway,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: organizationalUnit
|
||||
ou: company1
|
||||
description: First company in Norway
|
||||
|
||||
dn: cn=Some Person,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -67,7 +49,7 @@ sn: Person
|
||||
description: Sweden, Company1, Some Person
|
||||
telephoneNumber: +46 555-123456
|
||||
|
||||
dn: cn=Some Person2,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -79,7 +61,7 @@ sn: Person2
|
||||
description: Sweden, Company1, Some Person2
|
||||
telephoneNumber: +46 555-654321
|
||||
|
||||
dn: cn=Some Person3,ou=company1,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person3,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -91,7 +73,7 @@ sn: Person3
|
||||
description: Sweden, Company1, Some Person3
|
||||
telephoneNumber: +46 555-123654
|
||||
|
||||
dn: cn=Some Person,ou=company2,c=Sweden,dc=261consulting,dc=com
|
||||
dn: cn=Some Person,ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: person
|
||||
objectclass: organizationalPerson
|
||||
@@ -103,14 +85,18 @@ sn: Person
|
||||
description: Sweden, Company2, Some Person
|
||||
telephoneNumber: +46 555-456321
|
||||
|
||||
dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=261consulting,dc=com
|
||||
dn: cn=ROLE_USER,ou=groups,dc=261consulting,dc=com
|
||||
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
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_USER
|
||||
uniqueMember: cn=Some Person,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person,ou=company2,ou=Sweden,dc=261consulting,dc=com
|
||||
uniqueMember: cn=Some Person3,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
|
||||
dn: cn=ROLE_ADMIN,ou=groups,dc=261consulting,dc=com
|
||||
objectclass: top
|
||||
objectclass: groupOfUniqueNames
|
||||
cn: ROLE_ADMIN
|
||||
uniqueMember: cn=Some Person2,ou=company1,ou=Sweden,dc=261consulting,dc=com
|
||||
|
||||
|
||||
Reference in New Issue
Block a user