|
15 | 15 | */
|
16 | 16 | package org.springframework.security.ldap.authentication.ad;
|
17 | 17 |
|
| 18 | +import java.util.Collections; |
| 19 | +import java.util.Hashtable; |
| 20 | +import javax.naming.AuthenticationException; |
| 21 | +import javax.naming.CommunicationException; |
| 22 | +import javax.naming.Name; |
| 23 | +import javax.naming.NameNotFoundException; |
| 24 | +import javax.naming.NamingEnumeration; |
| 25 | +import javax.naming.NamingException; |
| 26 | +import javax.naming.directory.DirContext; |
| 27 | +import javax.naming.directory.SearchControls; |
| 28 | +import javax.naming.directory.SearchResult; |
| 29 | + |
18 | 30 | import org.apache.directory.shared.ldap.util.EmptyEnumeration;
|
19 | 31 | import org.hamcrest.BaseMatcher;
|
20 | 32 | import org.hamcrest.CoreMatchers;
|
|
25 | 37 | import org.junit.Test;
|
26 | 38 | import org.junit.rules.ExpectedException;
|
27 | 39 | import org.mockito.ArgumentCaptor;
|
| 40 | + |
28 | 41 | import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
29 | 42 | import org.springframework.ldap.core.DirContextAdapter;
|
30 | 43 | import org.springframework.ldap.core.DistinguishedName;
|
|
37 | 50 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
38 | 51 | import org.springframework.security.core.Authentication;
|
39 | 52 |
|
40 |
| -import javax.naming.AuthenticationException; |
41 |
| -import javax.naming.CommunicationException; |
42 |
| -import javax.naming.Name; |
43 |
| -import javax.naming.NameNotFoundException; |
44 |
| -import javax.naming.NamingEnumeration; |
45 |
| -import javax.naming.NamingException; |
46 |
| -import javax.naming.directory.DirContext; |
47 |
| -import javax.naming.directory.SearchControls; |
48 |
| -import javax.naming.directory.SearchResult; |
49 |
| - |
50 |
| -import java.util.Hashtable; |
51 |
| - |
52 | 53 | import static org.assertj.core.api.Assertions.assertThat;
|
53 | 54 | import static org.assertj.core.api.Assertions.fail;
|
54 |
| -import static org.mockito.Mockito.*; |
| 55 | +import static org.mockito.Mockito.any; |
| 56 | +import static org.mockito.Mockito.eq; |
| 57 | +import static org.mockito.Mockito.mock; |
| 58 | +import static org.mockito.Mockito.verify; |
| 59 | +import static org.mockito.Mockito.when; |
55 | 60 | import static org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider.ContextFactory;
|
56 | 61 |
|
57 | 62 | /**
|
@@ -398,6 +403,8 @@ public void nonAuthenticationExceptionIsConvertedToSpringLdapException() throws
|
398 | 403 | public void connectionExceptionIsWrappedInInternalException() throws Exception {
|
399 | 404 | ActiveDirectoryLdapAuthenticationProvider noneReachableProvider = new ActiveDirectoryLdapAuthenticationProvider(
|
400 | 405 | "mydomain.eu", NON_EXISTING_LDAP_PROVIDER, "dc=ad,dc=eu,dc=mydomain");
|
| 406 | + noneReachableProvider.setContextEnvironmentProperties( |
| 407 | + Collections.singletonMap("com.sun.jndi.ldap.connect.timeout", "5")); |
401 | 408 | noneReachableProvider.doAuthentication(joe);
|
402 | 409 | }
|
403 | 410 |
|
|
0 commit comments