Search in sources :

Example 1 with LdapSearchEntryHandlersProperties

use of org.apereo.cas.configuration.model.support.ldap.LdapSearchEntryHandlersProperties in project cas by apereo.

the class LdapUtilsTests method verifyComparePooling.

@Test
public void verifyComparePooling() throws Exception {
    val ldap = new Ldap();
    ldap.setBaseDn("ou=people,dc=example,dc=org|ou=users,dc=example,dc=org");
    ldap.setLdapUrl("ldap://localhost:10389");
    ldap.setBindDn("cn=Directory Manager");
    ldap.setBindCredential("password");
    ldap.setSearchFilter("cn=invalid-user");
    ldap.getValidator().setType("compare");
    val factory = LdapUtils.newLdaptivePooledConnectionFactory(ldap);
    val response = LdapUtils.executeSearchOperation(factory, ldap.getBaseDn(), LdapUtils.newLdaptiveSearchFilter(ldap.getSearchFilter()), 10, "cn");
    assertNotNull(response);
    assertFalse(LdapUtils.containsResultEntry(response));
    val config1 = LdapUtils.newLdaptiveConnectionConfig(ldap);
    assertNotNull(config1);
    Arrays.stream(LdapSearchEntryHandlersProperties.SearchEntryHandlerTypes.values()).forEach(type -> {
        val props = new LdapSearchEntryHandlersProperties();
        props.setType(type);
        props.getCaseChange().setAttributeNameCaseChange(CaseChangeEntryHandler.CaseChange.UPPER.name());
        props.getCaseChange().setDnCaseChange(CaseChangeEntryHandler.CaseChange.UPPER.name());
        props.getCaseChange().setAttributeValueCaseChange(CaseChangeEntryHandler.CaseChange.UPPER.name());
        ldap.getSearchEntryHandlers().add(props);
        val resolver = LdapUtils.newLdaptiveSearchEntryResolver(ldap, factory);
        assertNotNull(resolver);
    });
}
Also used : lombok.val(lombok.val) LdapSearchEntryHandlersProperties(org.apereo.cas.configuration.model.support.ldap.LdapSearchEntryHandlersProperties) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)1 LdapSearchEntryHandlersProperties (org.apereo.cas.configuration.model.support.ldap.LdapSearchEntryHandlersProperties)1 Test (org.junit.jupiter.api.Test)1