use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project gitblit by gitblit.
the class LdapBasedUnitTest method ldapInit.
/**
* Create three different in memory DS.
*
* Each DS has a different configuration:
* The first allows anonymous binds.
* The second requires authentication for all operations. It will only allow the DIRECTORY_MANAGER account
* to search for users and groups.
* The third one is like the second, but it allows users to search for users and groups, and restricts the
* USER_MANAGER from searching for groups.
*/
@BeforeClass
public static void ldapInit() throws Exception {
InMemoryDirectoryServer ds;
InMemoryDirectoryServerConfig config = createInMemoryLdapServerConfig(AuthMode.ANONYMOUS);
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("anonymous"));
ds = createInMemoryLdapServer(config);
AuthMode.ANONYMOUS.setDS(ds);
AuthMode.ANONYMOUS.setLdapPort(ds.getListenPort("anonymous"));
config = createInMemoryLdapServerConfig(AuthMode.DS_MANAGER);
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("ds_manager"));
config.setAuthenticationRequiredOperationTypes(EnumSet.allOf(OperationType.class));
ds = createInMemoryLdapServer(config);
AuthMode.DS_MANAGER.setDS(ds);
AuthMode.DS_MANAGER.setLdapPort(ds.getListenPort("ds_manager"));
config = createInMemoryLdapServerConfig(AuthMode.USR_MANAGER);
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("usr_manager"));
config.setAuthenticationRequiredOperationTypes(EnumSet.allOf(OperationType.class));
ds = createInMemoryLdapServer(config);
AuthMode.USR_MANAGER.setDS(ds);
AuthMode.USR_MANAGER.setLdapPort(ds.getListenPort("usr_manager"));
}
use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project gocd by gocd.
the class InMemoryLdapServerForTests method startServer.
private InMemoryDirectoryServer startServer(int port, String baseDn, String bindDn, String bindPassword) throws LDAPException, BindException {
InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", port);
InMemoryDirectoryServerConfig serverConfig = new InMemoryDirectoryServerConfig(new DN(baseDn));
/* Ignore schema so that it does not complain that some attributes (like sAMAccountName) are not valid. */
serverConfig.setSchema(null);
serverConfig.setListenerConfigs(listenerConfig);
serverConfig.addAdditionalBindCredentials(bindDn, bindPassword);
InMemoryDirectoryServer server = new InMemoryDirectoryServer(serverConfig);
try {
server.startListening();
} catch (LDAPException e) {
throw new RuntimeException(e);
}
new LDIFAddChangeRecord(baseDn, new Attribute("objectClass", "domain", "top")).processChange(server);
return server;
}
use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project gitblit by gitblit.
the class LdapBasedUnitTest method createInMemoryLdapServer.
public static InMemoryDirectoryServer createInMemoryLdapServer(InMemoryDirectoryServerConfig config) throws Exception {
InMemoryDirectoryServer imds = new InMemoryDirectoryServer(config);
imds.importFromLDIF(true, RESOURCE_DIR + "sampledata.ldif");
imds.startListening();
return imds;
}
use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project spring-boot by spring-projects.
the class EmbeddedLdapAutoConfigurationTests method testSetPartitionSuffix.
@Test
public void testSetPartitionSuffix() throws LDAPException {
load("spring.ldap.embedded.base-dn:dc=spring,dc=org");
InMemoryDirectoryServer server = this.context.getBean(InMemoryDirectoryServer.class);
assertThat(server.getBaseDNs()).containsExactly(new DN("dc=spring,dc=org"));
}
use of com.unboundid.ldap.listener.InMemoryDirectoryServer in project spring-boot by spring-projects.
the class EmbeddedLdapAutoConfigurationTests method testSetDefaultPort.
@Test
public void testSetDefaultPort() throws LDAPException {
load("spring.ldap.embedded.port:1234", "spring.ldap.embedded.base-dn:dc=spring,dc=org");
InMemoryDirectoryServer server = this.context.getBean(InMemoryDirectoryServer.class);
assertThat(server.getListenPort()).isEqualTo(1234);
}
Aggregations