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:
Luke Taylor 2009-06-03 17:13:33 +00:00
parent 6a18254ded
commit 01b8def455
1 changed files with 21 additions and 1 deletions

View File

@ -4,7 +4,10 @@ import static org.junit.Assert.*;
import java.util.Hashtable;
import javax.naming.directory.DirContext;
import org.junit.Test;
import org.springframework.ldap.AuthenticationException;
import org.springframework.ldap.core.support.AbstractContextSource;
@ -12,7 +15,7 @@ import org.springframework.ldap.core.support.AbstractContextSource;
* @author Luke Taylor
* @version $Id$
*/
public class DefaultSpringSecurityContextSourceTests {
public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegrationTests {
@Test
public void instantiationSucceedsWithExpectedProperties() {
@ -47,6 +50,23 @@ public class DefaultSpringSecurityContextSourceTests {
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 {
public EnvExposingDefaultSpringSecurityContextSource(String providerUrl) {
super(providerUrl);