Fix Formatting
This commit is contained in:
@@ -76,7 +76,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
LdapQuery query = LdapQueryBuilder.query().filter(filter);
|
||||
assertThatExceptionOfType(AuthenticationException.class)
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +86,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
LdapQuery query = LdapQueryBuilder.query().where("objectclass").is("person").and("uid").is("some.person3");
|
||||
assertThatExceptionOfType(AuthenticationException.class)
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,8 +114,10 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
@Category(NoAdTests.class)
|
||||
public void testAuthenticateWithLdapQueryAndMapper() {
|
||||
LdapQuery query = LdapQueryBuilder.query().where("objectclass").is("person").and("uid").is("some.person3");
|
||||
DirContextOperations ctx = this.tested.authenticate().query(query).password("password")
|
||||
.execute(new LookupAttemptingCallback());
|
||||
DirContextOperations ctx = this.tested.authenticate()
|
||||
.query(query)
|
||||
.password("password")
|
||||
.execute(new LookupAttemptingCallback());
|
||||
|
||||
assertThat(ctx).isNotNull();
|
||||
assertThat(ctx.getStringAttribute("uid")).isEqualTo("some.person3");
|
||||
@@ -126,7 +128,9 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
public void testAuthenticateWithLdapQueryAndMapperAndInvalidPassword() {
|
||||
LdapQuery query = LdapQueryBuilder.query().where("objectclass").is("person").and("uid").is("some.person3");
|
||||
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> this.tested.authenticate()
|
||||
.query(query).password("invalidpassword").execute(new LookupAttemptingCallback()));
|
||||
.query(query)
|
||||
.password("invalidpassword")
|
||||
.execute(new LookupAttemptingCallback()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +140,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
LdapQuery query = LdapQueryBuilder.query().filter(filter);
|
||||
assertThatExceptionOfType(AuthenticationException.class)
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,10 +148,10 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
public void testAuthenticateWithFilterThatDoesNotMatchAnything() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person"))
|
||||
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
|
||||
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
|
||||
LdapQuery query = LdapQueryBuilder.query().filter(filter);
|
||||
assertThatExceptionOfType(EmptyResultDataAccessException.class)
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,7 +161,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", "Some Person"));
|
||||
LdapQuery query = LdapQueryBuilder.query().filter(filter);
|
||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
|
||||
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -158,7 +158,7 @@ public class DefaultLdapClientBindUnbindITests extends AbstractLdapTemplateInteg
|
||||
|
||||
private void verifyCleanup() {
|
||||
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
|
||||
.isThrownBy(() -> this.tested.search().name(DN).toEntry());
|
||||
.isThrownBy(() -> this.tested.search().name(DN).toEntry());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DefaultLdapClientListITests extends AbstractLdapTemplateIntegration
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.listBindings("ou=company2,ou=Sweden" + BASE_STRING)
|
||||
.toList(this.contextMapper);
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,9 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
|
||||
@Test
|
||||
public void testLookup_AttributesMapper_LdapName() {
|
||||
AttributesMapper<Person> mapper = new PersonAttributesMapper();
|
||||
Person person = this.tested.search().name(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"))
|
||||
.toObject(mapper);
|
||||
Person person = this.tested.search()
|
||||
.name(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"))
|
||||
.toObject(mapper);
|
||||
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).isEqualTo("Person2");
|
||||
@@ -99,8 +100,8 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
|
||||
AttributesMapper<Person> mapper = new SubsetPersonAttributesMapper();
|
||||
|
||||
Person person = this.tested.search()
|
||||
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
|
||||
.toObject(mapper);
|
||||
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
|
||||
.toObject(mapper);
|
||||
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).as("lastName should not be set").isNull();
|
||||
@@ -114,10 +115,10 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
|
||||
@Test
|
||||
public void testLookup_ReturnAttributes_AttributesMapper_LdapName() {
|
||||
AttributesMapper<Person> mapper = new SubsetPersonAttributesMapper();
|
||||
Person person = this.tested
|
||||
.search().query((builder) -> builder
|
||||
.base(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden")).attributes("cn"))
|
||||
.toObject(mapper);
|
||||
Person person = this.tested.search()
|
||||
.query((builder) -> builder.base(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"))
|
||||
.attributes("cn"))
|
||||
.toObject(mapper);
|
||||
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).as("lastName should not be set").isNull();
|
||||
@@ -148,8 +149,8 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
|
||||
ContextMapper<Person> mapper = new PersonContextMapper();
|
||||
|
||||
Person person = this.tested.search()
|
||||
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
|
||||
.toObject(mapper);
|
||||
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
|
||||
.toObject(mapper);
|
||||
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).as("lastName should not be set").isNull();
|
||||
|
||||
@@ -76,8 +76,9 @@ public class DefaultLdapClientLookupMultiRdnITests extends AbstractLdapTemplateI
|
||||
@Test
|
||||
@Category(NoAdTests.class)
|
||||
public void testLookup_GetNameInNamespace_MultiRdn() {
|
||||
DirContextOperations result = this.tested.search().name("cn=Some Person+sn=Person,ou=company1,ou=Norway")
|
||||
.toEntry();
|
||||
DirContextOperations result = this.tested.search()
|
||||
.name("cn=Some Person+sn=Person,ou=company1,ou=Norway")
|
||||
.toEntry();
|
||||
assertThat(result.getDn().toString()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway");
|
||||
assertThat(result.getNameInNamespace()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway," + base);
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ public class DefaultLdapClientRecursiveDeleteITests extends AbstractLdapTemplate
|
||||
|
||||
private void verifyDeleted(Name dn) {
|
||||
assertThatExceptionOfType(NameNotFoundException.class)
|
||||
.describedAs("Expected entry '" + dn + "' to be non-existent")
|
||||
.isThrownBy(() -> this.tested.list(dn).toList(NameClassPair::getName));
|
||||
.describedAs("Expected entry '" + dn + "' to be non-existent")
|
||||
.isThrownBy(() -> this.tested.list(dn).toList(NameClassPair::getName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -117,9 +117,10 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper).collect(Collectors.toList());
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -128,8 +129,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
|
||||
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
|
||||
|
||||
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2")).toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -138,10 +146,16 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
|
||||
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
|
||||
|
||||
List<Object> list = this.tested
|
||||
.search().query(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn").where("objectclass")
|
||||
.is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper).collect(Collectors.toList());
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toStream(this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -150,9 +164,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -162,9 +182,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.ONELEVEL).where("objectclass")
|
||||
.is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper).collect(Collectors.toList());
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toStream(this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -173,9 +199,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -185,9 +217,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden").searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper).collect(Collectors.toList());
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toStream(this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -197,8 +235,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -208,8 +246,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper).collect(Collectors.toList());
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -218,9 +257,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -229,9 +268,10 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper).collect(Collectors.toList());
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -239,9 +279,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearch_SearchScope_AttributesMapper() {
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List<Object> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -250,9 +290,13 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
this.attributesMapper.setExpectedValues(CN_SN_VALUES);
|
||||
this.attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING)
|
||||
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS)
|
||||
.filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -260,8 +304,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearch_AttributesMapper_Name() {
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -270,8 +315,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -280,9 +325,13 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
this.attributesMapper.setExpectedValues(CN_SN_VALUES);
|
||||
this.attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME)
|
||||
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
List<Object> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS)
|
||||
.filter(FILTER_STRING))
|
||||
.toList(this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -291,7 +340,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING)).toList(this.contextMapper);
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -300,21 +350,25 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
DirContextAdapter result = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING)).toObject(this.contextMapper);
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING))
|
||||
.toObject(this.contextMapper);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectResultSizeDataAccessException.class)
|
||||
public void testSearchForObjectWithMultipleHits() {
|
||||
this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING).filter("(&(objectclass=person)(sn=*))"))
|
||||
.toObject((Object ctx) -> ctx);
|
||||
this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).filter("(&(objectclass=person)(sn=*))"))
|
||||
.toObject((Object ctx) -> ctx);
|
||||
}
|
||||
|
||||
@Test // (expected = EmptyResultDataAccessException.class)
|
||||
public void testSearchForObjectNoHits() {
|
||||
Object result = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).filter("(&(objectclass=person)(sn=Person does not exist))"))
|
||||
.toObject((Object ctx) -> ctx);
|
||||
Object result = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.filter("(&(objectclass=person)(sn=Person does not exist))"))
|
||||
.toObject((Object ctx) -> ctx);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@@ -322,9 +376,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearch_SearchScope_ContextMapper() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -333,9 +387,13 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
this.contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING)
|
||||
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS)
|
||||
.filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -344,7 +402,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING)).toList(this.contextMapper);
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -352,9 +411,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearch_ContextMapper_LdapQuery() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -362,9 +421,10 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearchForStream_ContextMapper_LdapQuery() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(
|
||||
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.contextMapper).collect(Collectors.toList());
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -373,8 +433,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -383,8 +443,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.contextMapper).collect(Collectors.toList());
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -392,9 +453,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -403,9 +470,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.ONELEVEL).where("objectclass")
|
||||
.is("person").and("sn").is("Person2"))
|
||||
.toStream(this.contextMapper).collect(Collectors.toList());
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toStream(this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -413,9 +486,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -424,9 +503,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden").searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toStream(this.contextMapper).collect(Collectors.toList());
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toStream(this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -434,16 +519,22 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearchForContext_LdapQuery() {
|
||||
ContextMapper<DirContextOperations> mapper = (result) -> (DirContextOperations) result;
|
||||
DirContextOperations result = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toObject(mapper);
|
||||
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toObject(mapper);
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
}
|
||||
|
||||
@Test // (expected = EmptyResultDataAccessException.class)
|
||||
public void testSearchForContext_LdapQuery_SearchScopeNotFound() {
|
||||
Object result = this.tested.search().query(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2")).toObject(this.attributesMapper);
|
||||
Object result = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toObject(this.attributesMapper);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@@ -451,9 +542,14 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() {
|
||||
ContextMapper<DirContextOperations> mapper = (result) -> (DirContextOperations) result;
|
||||
DirContextOperations result = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL).base("ou=company1,ou=Sweden")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"))
|
||||
.toObject(mapper);
|
||||
.query(LdapQueryBuilder.query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"))
|
||||
.toObject(mapper);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
@@ -464,8 +560,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -474,19 +570,26 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
this.contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME)
|
||||
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS)
|
||||
.filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithInvalidSearchBaseShouldByDefaultThrowException() {
|
||||
try {
|
||||
this.tested
|
||||
.search().query(LdapQueryBuilder.query().base(BASE_NAME + "ou=unknown")
|
||||
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
|
||||
.toObject(this.contextMapper);
|
||||
this.tested.search()
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME + "ou=unknown")
|
||||
.searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS)
|
||||
.filter(FILTER_STRING))
|
||||
.toObject(this.contextMapper);
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
@@ -501,17 +604,20 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
this.contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List<DirContextAdapter> list = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().base(BASE_NAME + "ou=unknown").searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS).filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
.query(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME + "ou=unknown")
|
||||
.searchScope(SearchScope.SUBTREE)
|
||||
.attributes(CN_SN_ATTRS)
|
||||
.filter(FILTER_STRING))
|
||||
.toList(this.contextMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyThatSearchWithCountLimitReturnsTheEntriesFoundSoFar() {
|
||||
List<Object> result = this.tested.search()
|
||||
.query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
|
||||
.toList((Object ctx) -> new Object());
|
||||
.query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
|
||||
.toList((Object ctx) -> new Object());
|
||||
|
||||
assertThat(result).hasSize(3);
|
||||
}
|
||||
@@ -519,8 +625,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
|
||||
@Test(expected = SizeLimitExceededException.class)
|
||||
public void verifyThatSearchWithCountLimitWithFlagToFalseThrowsException() {
|
||||
ReflectionTestUtils.setField(this.tested, "ignoreSizeLimitExceededException", false);
|
||||
this.tested.search().query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
|
||||
.toList((Object ctx) -> ctx);
|
||||
this.tested.search()
|
||||
.query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
|
||||
.toList((Object ctx) -> ctx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,9 +134,11 @@ public class LdapTemplateAuthenticationITests extends AbstractLdapTemplateIntegr
|
||||
final Exception error = errorCallback.getError();
|
||||
assertThat(error).as("collected error should not be null").isNotNull();
|
||||
assertThat(error instanceof AuthenticationException)
|
||||
.as("expected org.springframework.ldap.AuthenticationException").isTrue();
|
||||
.as("expected org.springframework.ldap.AuthenticationException")
|
||||
.isTrue();
|
||||
assertThat(error.getCause() instanceof javax.naming.AuthenticationException)
|
||||
.as("expected javax.naming.AuthenticationException").isTrue();
|
||||
.as("expected javax.naming.AuthenticationException")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +146,7 @@ public class LdapTemplateAuthenticationITests extends AbstractLdapTemplateIntegr
|
||||
public void testAuthenticateWithFilterThatDoesNotMatchAnything() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person"))
|
||||
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
|
||||
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
|
||||
assertThat(this.tested.authenticate("", filter.toString(), "password")).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class LdapTemplateLookupMultiRdnITests extends AbstractLdapTemplateIntegr
|
||||
@Category(NoAdTests.class)
|
||||
public void testLookup_MultiValuedRdn_DirContextAdapter() {
|
||||
DirContextAdapter result = (DirContextAdapter) this.tested
|
||||
.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway");
|
||||
.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway");
|
||||
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person");
|
||||
@@ -80,7 +80,7 @@ public class LdapTemplateLookupMultiRdnITests extends AbstractLdapTemplateIntegr
|
||||
@Category(NoAdTests.class)
|
||||
public void testLookup_GetNameInNamespace_MultiRdn() {
|
||||
DirContextAdapter result = (DirContextAdapter) this.tested
|
||||
.lookup("cn=Some Person+sn=Person,ou=company1,ou=Norway");
|
||||
.lookup("cn=Some Person+sn=Person,ou=company1,ou=Norway");
|
||||
|
||||
assertThat(result.getDn().toString()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway");
|
||||
assertThat(result.getNameInNamespace()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway," + base);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class LdapTemplateNoBaseSuffixITests extends AbstractLdapTemplateIntegrat
|
||||
this.tested.bind("cn=Some Person4, ou=company1, ou=Sweden," + base, adapter, null);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) this.tested
|
||||
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
|
||||
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
|
||||
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
|
||||
|
||||
@@ -121,7 +121,8 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
|
||||
List<Object> list = this.tested.searchForStream(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper).collect(Collectors.toList());
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -130,8 +131,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
|
||||
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
|
||||
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper);
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -140,9 +146,15 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
|
||||
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
|
||||
|
||||
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -151,9 +163,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper);
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -163,9 +179,14 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -174,9 +195,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper);
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -185,9 +210,15 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper).collect(Collectors.toList());
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -208,9 +239,9 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -232,7 +263,8 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
|
||||
List<Object> list = this.tested.searchForStream(
|
||||
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper).collect(Collectors.toList());
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -358,9 +390,11 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
public void testSearchForStream_ContextMapper_LdapQuery() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.searchForStream(
|
||||
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper).collect(Collectors.toList());
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(
|
||||
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -378,9 +412,9 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -388,9 +422,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -399,9 +437,14 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -409,9 +452,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -420,17 +467,21 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForContext_LdapQuery() {
|
||||
DirContextOperations result = this.tested
|
||||
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
|
||||
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
@@ -438,15 +489,23 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
|
||||
|
||||
@Test(expected = EmptyResultDataAccessException.class)
|
||||
public void testSearchForContext_LdapQuery_SearchScopeNotFound() {
|
||||
this.tested.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL).where("objectclass")
|
||||
.is("person").and("sn").is("Person2"));
|
||||
this.tested.searchForContext(LdapQueryBuilder.query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() {
|
||||
DirContextOperations result = this.tested
|
||||
.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,ou=Sweden").where("objectclass").is("person").and("sn").is("Person2"));
|
||||
DirContextOperations result = this.tested.searchForContext(LdapQueryBuilder.query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"));
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
|
||||
@@ -118,7 +118,8 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
|
||||
List<Object> list = this.tested.searchForStream(
|
||||
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper).collect(Collectors.toList());
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -127,8 +128,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
|
||||
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
|
||||
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper);
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -137,9 +143,15 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
|
||||
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
|
||||
|
||||
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -148,9 +160,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper);
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -160,9 +176,14 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -171,9 +192,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper);
|
||||
List<Object> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -182,9 +207,15 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper).collect(Collectors.toList());
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -205,9 +236,9 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -229,7 +260,8 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
|
||||
List<Object> list = this.tested.searchForStream(
|
||||
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.attributesMapper).collect(Collectors.toList());
|
||||
this.attributesMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -355,9 +387,11 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
public void testSearchForStream_ContextMapper_LdapQuery() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.searchForStream(
|
||||
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper).collect(Collectors.toList());
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(
|
||||
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -375,9 +409,9 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -385,9 +419,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper);
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -396,9 +434,14 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"), this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@@ -406,9 +449,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper);
|
||||
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper);
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -417,17 +464,21 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
this.contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = this.tested
|
||||
.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
|
||||
this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
.searchForStream(LdapQueryBuilder.query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"), this.contextMapper)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForContext_LdapQuery() {
|
||||
DirContextOperations result = this.tested
|
||||
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
|
||||
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
@@ -435,15 +486,23 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
|
||||
|
||||
@Test(expected = EmptyResultDataAccessException.class)
|
||||
public void testSearchForContext_LdapQuery_SearchScopeNotFound() {
|
||||
this.tested.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL).where("objectclass")
|
||||
.is("person").and("sn").is("Person2"));
|
||||
this.tested.searchForContext(LdapQueryBuilder.query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() {
|
||||
DirContextOperations result = this.tested
|
||||
.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,ou=Sweden").where("objectclass").is("person").and("sn").is("Person2"));
|
||||
DirContextOperations result = this.tested.searchForContext(LdapQueryBuilder.query()
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass")
|
||||
.is("person")
|
||||
.and("sn")
|
||||
.is("Person2"));
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SupportedControlsITests extends AbstractLdapTemplateIntegrationTest
|
||||
HashSet<String> controlsSet = new HashSet<String>(Arrays.asList(controls));
|
||||
|
||||
assertThat(controlsSet.contains("1.3.6.1.4.1.4203.1.10.1")).as("Entry Change Notification LDAPv3 control,")
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(controlsSet.contains("1.3.6.1.4.1.4203.1.10.1")).as("Subentries Control,").isTrue();
|
||||
assertThat(controlsSet.contains("2.16.840.1.113730.3.4.2")).as("Manage DSA IT LDAPv3 control,").isTrue();
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class SimpleLdapTemplateITests extends AbstractLdapTemplateIntegrationTes
|
||||
@Test
|
||||
public void testModifyAttributesName() {
|
||||
DirContextOperations ctx = this.ldapTemplate
|
||||
.lookupContext(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden"));
|
||||
.lookupContext(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden"));
|
||||
|
||||
ctx.setAttributeValue("description", "updated description");
|
||||
ctx.setAttributeValue("telephoneNumber", "0000001");
|
||||
|
||||
@@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class);
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
@@ -75,7 +75,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extend
|
||||
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
this.jdbcTemplate
|
||||
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
|
||||
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
|
||||
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
|
||||
new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests
|
||||
extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class);
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
|
||||
@@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class);
|
||||
.getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
@@ -76,7 +76,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends
|
||||
|
||||
this.jdbcTemplate.execute("drop table PERSON if exists");
|
||||
this.jdbcTemplate
|
||||
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
|
||||
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
|
||||
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
|
||||
new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
public class ContextSourceAndHibernateTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class);
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests
|
||||
extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class);
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
|
||||
@@ -58,7 +58,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
public class ContextSourceAndHibernateTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class);
|
||||
.getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("dummyDao")
|
||||
|
||||
@@ -60,8 +60,8 @@ public class LdapTemplateOdmWithDnAnnotationsITests extends AbstractLdapTemplate
|
||||
|
||||
@Test
|
||||
public void testFindByDn() {
|
||||
PersonWithDnAnnotations person = this.tested.findByDn(
|
||||
LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), PersonWithDnAnnotations.class);
|
||||
PersonWithDnAnnotations person = this.tested
|
||||
.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), PersonWithDnAnnotations.class);
|
||||
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
@@ -77,8 +77,8 @@ public class LdapTemplateOdmWithDnAnnotationsITests extends AbstractLdapTemplate
|
||||
|
||||
@Test
|
||||
public void testFindInCountry() {
|
||||
List<PersonWithDnAnnotations> persons = this.tested.find(
|
||||
LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), PersonWithDnAnnotations.class);
|
||||
List<PersonWithDnAnnotations> persons = this.tested
|
||||
.find(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), PersonWithDnAnnotations.class);
|
||||
|
||||
assertThat(persons).hasSize(4);
|
||||
|
||||
@@ -93,9 +93,9 @@ public class LdapTemplateOdmWithDnAnnotationsITests extends AbstractLdapTemplate
|
||||
@Test
|
||||
public void testFindForStreamInCountry() {
|
||||
List<PersonWithDnAnnotations> persons = this.tested
|
||||
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(),
|
||||
PersonWithDnAnnotations.class)
|
||||
.collect(Collectors.toList());
|
||||
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(),
|
||||
PersonWithDnAnnotations.class)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(persons).hasSize(4);
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ public class LdapTemplateOdmWithNoDnAnnotationsITests extends AbstractLdapTempla
|
||||
@Test
|
||||
public void testFindForStream() {
|
||||
List<Person> persons = this.tested
|
||||
.findForStream(LdapQueryBuilder.query().where("cn").is("Some Person3"), Person.class)
|
||||
.collect(Collectors.toList());
|
||||
.findForStream(LdapQueryBuilder.query().where("cn").is("Some Person3"), Person.class)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(persons).hasSize(1);
|
||||
Person person = persons.get(0);
|
||||
@@ -125,8 +125,8 @@ public class LdapTemplateOdmWithNoDnAnnotationsITests extends AbstractLdapTempla
|
||||
@Test
|
||||
public void testFindForStreamInCountry() {
|
||||
List<Person> persons = this.tested
|
||||
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), Person.class)
|
||||
.collect(Collectors.toList());
|
||||
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), Person.class)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(persons).hasSize(4);
|
||||
Person person = persons.get(0);
|
||||
|
||||
Reference in New Issue
Block a user