@Bean
    @ConditionalOnMissingBean
    public LdapContextSource contextSource(final LdapProperties ldapProp) {
        LdapContextSource contextSource = new LdapContextSource();
        contextSource.setUrl(ldapProp.getUrl());
        contextSource.setUserDn(ldapProp.getBindDn());
        contextSource.setPassword(ldapProp.getPassword());
        contextSource.setPooled(true);
        Map<String, Object> config = new HashMap<>();
        config.put("java.naming.ldap.attributes.binary", "objectGUID");
        config.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(ldapProp.getConnectTimeout()));
        config.put("com.sun.jndi.ldap.read.timeout", String.valueOf(ldapProp.getReadTimeout()));
        contextSource.setBaseEnvironmentProperties(config);
        return contextSource;
    }
@Test
    public void testContextSource() {
        LdapProperties ldapProp = mock(LdapProperties.class);
        String ldapUrl = "ldap://192.168.0.10:389";
        String user = "test";
        String pass = "123";
        when(ldapProp.getUrl()).thenReturn(ldapUrl);
        when(ldapProp.getBindDn()).thenReturn(user);
        when(ldapProp.getPassword()).thenReturn(pass);
        when(ldapProp.getConnectTimeout()).thenReturn(5000);
        when(ldapProp.getReadTimeout()).thenReturn(10000);
        LdapContextSource ldapContextSource = ldapConfiguration.contextSource(ldapProp);
        assertNotNull(ldapContextSource);
        assertThat(ldapContextSource.getUrls().length, is(1));
        assertEquals(ldapContextSource.getUrls()[0], ldapUrl);
        assertEquals(ldapContextSource.getUserDn(), user);
        assertEquals(ldapContextSource.getPassword(), pass);
    }