SEC-1145: Added test to confirm that there is no pooling issue in the trunk. There are already checks for the presence of the pooling flag.
This commit is contained in:
parent
6a18254ded
commit
01b8def455
|
@ -4,7 +4,10 @@ import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import javax.naming.directory.DirContext;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.springframework.ldap.AuthenticationException;
|
||||||
import org.springframework.ldap.core.support.AbstractContextSource;
|
import org.springframework.ldap.core.support.AbstractContextSource;
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +15,7 @@ import org.springframework.ldap.core.support.AbstractContextSource;
|
||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class DefaultSpringSecurityContextSourceTests {
|
public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void instantiationSucceedsWithExpectedProperties() {
|
public void instantiationSucceedsWithExpectedProperties() {
|
||||||
|
@ -47,6 +50,23 @@ public class DefaultSpringSecurityContextSourceTests {
|
||||||
assertFalse(ctxSrc.getAuthenticatedEnvForTest("user", "password").containsKey(AbstractContextSource.SUN_LDAP_POOLING_FLAG));
|
assertFalse(ctxSrc.getAuthenticatedEnvForTest("user", "password").containsKey(AbstractContextSource.SUN_LDAP_POOLING_FLAG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SEC-1145. Confirms that there is no issue here with pooling.
|
||||||
|
@Test(expected=AuthenticationException.class)
|
||||||
|
public void cantBindWithWrongPasswordImmediatelyAfterSuccessfulBind() throws Exception {
|
||||||
|
DirContext ctx = null;
|
||||||
|
try {
|
||||||
|
ctx = getContextSource().getContext("uid=Bob,ou=people,dc=springframework,dc=org", "bobspassword");
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
assertNotNull(ctx);
|
||||||
|
// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
|
||||||
|
ctx.close();
|
||||||
|
// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
|
||||||
|
// Now get it gain, with wrong password. Should fail.
|
||||||
|
ctx = getContextSource().getContext("uid=Bob,ou=people,dc=springframework,dc=org", "wrongpassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static class EnvExposingDefaultSpringSecurityContextSource extends DefaultSpringSecurityContextSource {
|
static class EnvExposingDefaultSpringSecurityContextSource extends DefaultSpringSecurityContextSource {
|
||||||
public EnvExposingDefaultSpringSecurityContextSource(String providerUrl) {
|
public EnvExposingDefaultSpringSecurityContextSource(String providerUrl) {
|
||||||
super(providerUrl);
|
super(providerUrl);
|
||||||
|
|
Loading…
Reference in New Issue