Skip to content

Commit

Permalink
Populate base for embedded LDAPContextSource
Browse files Browse the repository at this point in the history
Fixes gh-23030
  • Loading branch information
mbhave committed Oct 7, 2022
1 parent 533f301 commit 263433c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Expand Up @@ -205,6 +205,7 @@ static class EmbeddedLdapContextConfiguration {
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());
Expand Down
Expand Up @@ -178,6 +178,15 @@ void ldapContextWithoutSpringLdapIsNotCreated() {
});
}

@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 {

Expand Down

0 comments on commit 263433c

Please sign in to comment.