forked from spring-projects/spring-ldap
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set anonymousReadOnly true when userDn is not provided
Fixes spring-projectsgh-473
- Loading branch information
1 parent
dc4fe89
commit 04a6669
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
test/integration-tests/src/test/java/org/springframework/ldap/itest/ldap473/Ldap473Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.springframework.ldap.itest.ldap473; | ||
|
||
import javax.naming.directory.DirContext; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.ldap.core.ContextSource; | ||
import org.springframework.ldap.core.support.LdapContextSource; | ||
import org.springframework.ldap.test.EmbeddedLdapServerFactoryBean; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Eddú Meléndez | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
public class Ldap473Test { | ||
|
||
@Autowired | ||
private ContextSource contextSource; | ||
|
||
@Test | ||
public void anonymous() { | ||
DirContext readOnlyContext = contextSource.getReadOnlyContext(); | ||
assertThat(readOnlyContext).isNotNull(); | ||
} | ||
|
||
@Configuration | ||
static class ContextSourceConfig { | ||
|
||
@Bean | ||
public ContextSource contextSource() { | ||
LdapContextSource contextSource = new LdapContextSource(); | ||
contextSource.setUrl("ldap://localhost:9321"); | ||
contextSource.setUserDn(null); | ||
contextSource.setPassword(null); | ||
return contextSource; | ||
} | ||
|
||
} | ||
|
||
@Configuration | ||
static class EmbeddedLdapConfig { | ||
|
||
@Bean | ||
public EmbeddedLdapServerFactoryBean embeddedLdapServer() { | ||
EmbeddedLdapServerFactoryBean embeddedLdapServer = new EmbeddedLdapServerFactoryBean(); | ||
embeddedLdapServer.setPartitionName("example"); | ||
embeddedLdapServer.setPartitionSuffix("dc=261consulting,dc=com"); | ||
embeddedLdapServer.setPort(9321); | ||
return embeddedLdapServer; | ||
} | ||
|
||
} | ||
|
||
} |