-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Labels
status: duplicateA duplicate of another issueA duplicate of another issue
Description
Spring ldap autoconfiguration provides spring.ldap.base which is used when ContextSource for LdapTemplate is created.
For example:
When I specify spring.ldap.base=dc=company,dc=com I do not need specify whole DN (uid=<username>,dc=company,dc=com) when searching in ldap:
function User findUser(username) {
return ldapTemplate.lookup("uid=" + username, ldapUserContextMapper);
}
But I get in trouble when testing function above with embedded ldap, because contextSource created with EmbeddedLdapAutoConfiguration does not obtain base property from spring.ldap.base environment property.
Embedded ldap configuration:
spring.ldap.embedded.ldif=classpath:test-ldap.ldif
spring.ldap.embedded.validation.schema=classpath:test-ldap-schema.ldif
spring.ldap.embedded.base-dn=dc=company,dc=com
# spring ldap base is ignored by EmbeddedLdapAutoConfiguration
spring.ldap.base=dc=company,dc=com
Of course, I can provide custom ContextSource bean and setup base programatically for JUnit tests purpose.
@Bean
@ConditionalOnProperty(name = {"spring.ldap.embedded.port", "spring.ldap.base"})
public LdapContextSource contextSource(EmbeddedLdapProperties embeddedProperties, LdapProperties ldapProperties) {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setBase(ldapProperties.getBase());
ldapContextSource.setUrl("ldap://localhost:" + embeddedProperties.getPort());
return ldapContextSource;
}
But simple one line in application.properties would simplify my JUnit tests.
Metadata
Metadata
Assignees
Labels
status: duplicateA duplicate of another issueA duplicate of another issue