Skip to content

Commit 263433c

Browse files
committed
Populate base for embedded LDAPContextSource
Fixes gh-23030
1 parent 533f301 commit 263433c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static class EmbeddedLdapContextConfiguration {
205205
LdapContextSource ldapContextSource(Environment environment, LdapProperties properties,
206206
EmbeddedLdapProperties embeddedProperties) {
207207
LdapContextSource source = new LdapContextSource();
208+
source.setBase(properties.getBase());
208209
if (embeddedProperties.getCredential().isAvailable()) {
209210
source.setUserDn(embeddedProperties.getCredential().getUsername());
210211
source.setPassword(embeddedProperties.getCredential().getPassword());

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfigurationTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ void ldapContextWithoutSpringLdapIsNotCreated() {
178178
});
179179
}
180180

181+
@Test
182+
void ldapContextIsCreatedWithBase() {
183+
this.contextRunner.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org",
184+
"spring.ldap.base:dc=spring,dc=org").run((context) -> {
185+
LdapContextSource ldapContextSource = context.getBean(LdapContextSource.class);
186+
assertThat(ldapContextSource.getBaseLdapPathAsString()).isEqualTo("dc=spring,dc=org");
187+
});
188+
}
189+
181190
@Configuration(proxyBeanMethods = false)
182191
static class LdapClientConfiguration {
183192

0 commit comments

Comments
 (0)