瀏覽代碼

SEC-1145: Updated LDAP code to make sure pooling flag is removed when binding as a specific user (for real this time)

Luke Taylor 16 年之前
父節點
當前提交
781c99f257

+ 13 - 0
core/src/test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java

@@ -5,6 +5,7 @@ import static org.junit.Assert.assertNull;
 import javax.naming.directory.DirContext;
 
 import org.junit.Test;
+import org.springframework.security.BadCredentialsException;
 
 /**
  * @author Luke Taylor
@@ -30,4 +31,16 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
         ctx.close();
     }
 
+    @Test(expected=BadCredentialsException.class)
+    public void poolingIsntUsedForSingleUser2() throws Exception {
+        DirContext ctx = getContextSource().getReadWriteContext("uid=Bob,ou=people,dc=springframework,dc=org", "bobspassword");
+        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
+        ctx = getContextSource().getReadWriteContext("uid=Bob,ou=people,dc=springframework,dc=org", "wrongpassword");
+        com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
+    }
+
+
 }