瀏覽代碼

Some additional tests to confirm there are no issues with spaces in LDAP URL.

Luke Taylor 14 年之前
父節點
當前提交
428991d997

+ 1 - 0
ldap/ldap.gradle

@@ -36,6 +36,7 @@ integrationTest {
     systemProperties['apacheDSWorkDir'] = "${buildDir}/apacheDSWork"
 }
 
+// Runs a server for running the integration tests against (from an IDE, for example)
 task(ldapServer, dependsOn: 'integrationTestClasses', type: JavaExec) {
     classpath = sourceSets.integrationTest.runtimeClasspath
     main = 'org.springframework.security.ldap.ApacheDSServerIntegrationTests'

+ 8 - 0
ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java

@@ -63,8 +63,16 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
 //        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");
+        ctx.close();
     }
 
+    @Test
+    public void serverUrlWithSpacesIsSupported() throws Exception {
+        DefaultSpringSecurityContextSource
+                contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:53389/ou=space%20cadets,dc=springframework,dc=org");
+        contextSource.afterPropertiesSet();
+        contextSource.getContext("uid=space cadet,ou=space cadets,dc=springframework,dc=org", "spacecadetspassword");
+    }
 
     static class EnvExposingDefaultSpringSecurityContextSource extends DefaultSpringSecurityContextSource {
         public EnvExposingDefaultSpringSecurityContextSource(String providerUrl) {

+ 16 - 0
ldap/src/integration-test/resources/test-server.ldif

@@ -13,6 +13,11 @@ objectclass: top
 objectclass: organizationalUnit
 ou: people
 
+dn: ou=space cadets,dc=springframework,dc=org
+objectclass: top
+objectclass: organizationalUnit
+ou: space cadets
+
 dn: ou=\"quoted people\",dc=springframework,dc=org
 objectclass: top
 objectclass: organizationalUnit
@@ -83,6 +88,17 @@ sn: Quote
 uid: quoteguy
 userPassword: quoteguyspassword
 
+dn: uid=space cadet,ou=space cadets,dc=springframework,dc=org
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+cn: Space Cadet
+sn: Cadet
+uid: space cadet
+userPassword: spacecadetspassword
+
+
 
 dn: cn=developers,ou=groups,dc=springframework,dc=org
 objectclass: top