Reuse spring.ldap.base in Embedded support

Closes gh-10444
This commit is contained in:
David Pavel 2017-09-28 13:02:15 +02:00 committed by Stephane Nicoll
parent 5a13a32f6c
commit 0fbc5def32
2 changed files with 16 additions and 0 deletions

View File

@ -98,6 +98,7 @@ public class EmbeddedLdapAutoConfiguration {
source.setPassword(this.embeddedProperties.getCredential().getPassword());
}
source.setUrls(this.properties.determineUrls(this.environment));
source.setBase(this.properties.getBase());
return source;
}

View File

@ -131,6 +131,21 @@ public class EmbeddedLdapAutoConfigurationTests {
assertThat(ldapTemplate.list("ou=company1,c=Sweden,dc=spring,dc=org")).hasSize(4);
}
@Test
public void testQueryEmbeddedLdapWithBase() throws LDAPException {
TestPropertyValues.of("spring.ldap.embedded.base-dn:dc=spring,dc=org",
"spring.ldap.base:dc=spring,dc=org")
.applyTo(this.context);
this.context.register(EmbeddedLdapAutoConfiguration.class,
LdapAutoConfiguration.class, LdapDataAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBeanNamesForType(LdapTemplate.class).length)
.isEqualTo(1);
LdapTemplate ldapTemplate = this.context.getBean(LdapTemplate.class);
assertThat(ldapTemplate.list("ou=company1,c=Sweden")).hasSize(4);
}
@Test
public void testDisableSchemaValidation() throws LDAPException {
load("spring.ldap.embedded.validation.enabled:false",