use of org.springframework.ldap.core.LdapTemplate in project gocd by gocd.
the class LdapUserSearchTest method setUp.
@Before
public void setUp() {
goConfigService = mock(GoConfigService.class);
contextFactory = mock(SpringSecurityContextSource.class);
securityConfig = mock(SecurityConfig.class);
ldapTemplate = mock(LdapTemplate.class);
logger = mock(Logger.class);
ldapUserSearch = new LdapUserSearch(goConfigService, contextFactory, ldapTemplate, logger);
when(goConfigService.security()).thenReturn(securityConfig);
spy = spy(ldapUserSearch);
}
use of org.springframework.ldap.core.LdapTemplate in project camel by apache.
the class SpringLdapProducerTest method testFunctionDriven.
@Test
public void testFunctionDriven() throws Exception {
String dn = "cn=dn";
Exchange exchange = new DefaultExchange(context);
Message in = new DefaultMessage();
Map<String, Object> body = new HashMap<String, Object>();
body.put(SpringLdapProducer.DN, dn);
body.put(SpringLdapProducer.REQUEST, dn);
body.put(SpringLdapProducer.FUNCTION, (BiFunction<LdapOperations, String, Void>) (l, q) -> {
l.lookup(q);
return null;
});
when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.FUNCTION_DRIVEN);
processBody(exchange, in, body);
verify(ldapTemplate).lookup(eq(dn));
}
use of org.springframework.ldap.core.LdapTemplate in project jBPM5-Developer-Guide by Salaboy.
the class ProcessAndHumanTasksTest method setUp.
@Before
public void setUp() throws Exception {
container = new ApacheDSContainer("o=mojo", "classpath:identity-repository.ldif");
container.setPort(9898);
container.afterPropertiesSet();
LdapContextSource cs = new LdapContextSource();
cs.setUrl("ldap://localhost:9898/");
cs.setBase("o=mojo");
cs.setUserDn("uid=admin,ou=system");
cs.setPassword("secret");
cs.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(cs);
ldapTemplate.afterPropertiesSet();
ldapQuery = new LdapQueryHelper(ldapTemplate);
// By Setting the jbpm.usergroup.callback property with the call
// back class full name, task service will use this to validate the
// user/group exists and its permissions are ok.
System.setProperty("jbpm.usergroup.callback", "org.jbpm.task.identity.LDAPUserGroupCallbackImpl");
// LdapUserGroupCallback callback = (LdapUserGroupCallback) UserGroupCallbackManager.getInstance().getCallback();
// callback.setQuery(ldapQuery);
}
use of org.springframework.ldap.core.LdapTemplate in project spring-security by spring-projects.
the class LdapServerBeanDefinitionParserTests method embeddedServerCreationContainsExpectedContextSourceAndData.
@Test
public void embeddedServerCreationContainsExpectedContextSourceAndData() {
appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>");
DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) appCtx.getBean(BeanIds.CONTEXT_SOURCE);
// Check data is loaded
LdapTemplate template = new LdapTemplate(contextSource);
template.lookup("uid=ben,ou=people");
}
use of org.springframework.ldap.core.LdapTemplate in project spring-boot by spring-projects.
the class EmbeddedLdapAutoConfigurationTests method testQueryEmbeddedLdap.
@Test
public void testQueryEmbeddedLdap() throws LDAPException {
EnvironmentTestUtils.addEnvironment(this.context, "spring.ldap.embedded.base-dn:dc=spring,dc=org");
this.context.register(EmbeddedLdapAutoConfiguration.class, LdapAutoConfiguration.class, LdapDataAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBeanNamesForType(LdapTemplate.class).length).isEqualTo(1);
LdapTemplate ldapTemplate = this.context.getBean(LdapTemplate.class);
assertThat(ldapTemplate.list("ou=company1,c=Sweden,dc=spring,dc=org")).hasSize(4);
}
Aggregations