Populate base for embedded LDAPContextSource

Fixes gh-23030
pull/32643/head
Madhura Bhave 2 years ago
parent 533f3017d4
commit 263433cd81

@ -205,6 +205,7 @@ public class EmbeddedLdapAutoConfiguration {
LdapContextSource ldapContextSource(Environment environment, LdapProperties properties,
EmbeddedLdapProperties embeddedProperties) {
LdapContextSource source = new LdapContextSource();
source.setBase(properties.getBase());
if (embeddedProperties.getCredential().isAvailable()) {
source.setUserDn(embeddedProperties.getCredential().getUsername());
source.setPassword(embeddedProperties.getCredential().getPassword());

@ -178,6 +178,15 @@ class EmbeddedLdapAutoConfigurationTests {
});
}
@Test
void ldapContextIsCreatedWithBase() {
this.contextRunner.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org",
"spring.ldap.base:dc=spring,dc=org").run((context) -> {
LdapContextSource ldapContextSource = context.getBean(LdapContextSource.class);
assertThat(ldapContextSource.getBaseLdapPathAsString()).isEqualTo("dc=spring,dc=org");
});
}
@Configuration(proxyBeanMethods = false)
static class LdapClientConfiguration {

Loading…
Cancel
Save