Browse Source

SEC-1255: Replace file with controller to avoid windows filename problems

3.0.x
Luke Taylor 17 years ago
parent
commit
c9e2121504
  1. 11
      itest/web/pom.xml
  2. 19
      itest/web/src/main/java/org/springframework/security/itest/web/TestController.java
  3. 4
      itest/web/src/main/webapp/WEB-INF/http-security.xml
  4. 12
      itest/web/src/main/webapp/secure/file?with?special?chars.html
  5. 7
      itest/web/src/test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java
  6. 4
      itest/web/src/test/java/org/springframework/security/integration/InMemoryProviderWebAppTests.java

11
itest/web/pom.xml

@ -24,6 +24,10 @@ @@ -24,6 +24,10 @@
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
@ -48,12 +52,5 @@ @@ -48,12 +52,5 @@
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-api-2.1</artifactId>
<version>${jetty.version}</version>
</dependency>
-->
</dependencies>
</project>

19
itest/web/src/main/java/org/springframework/security/itest/web/TestController.java

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
package org.springframework.security.itest.web;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class TestController {
@RequestMapping(value="/secure/file?with?special?chars.htm", method=RequestMethod.GET)
public void sec1255TestUrl(HttpServletResponse response) throws IOException {
response.getWriter().append("I'm file?with?special?chars.htm");
}
}

4
itest/web/src/main/webapp/WEB-INF/http-security.xml

@ -24,13 +24,11 @@ @@ -24,13 +24,11 @@
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
</session-management>
<remember-me key="doesntmatter" token-repository-ref="tokenRepo"/>
</http>
<beans:bean name="tokenRepo" class="org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl"/>
<!-- bean name="rememberMeServices" class="org.springframework.security.ui.rememberme.NullRememberMeServices"/ -->
</beans:beans>

12
itest/web/src/main/webapp/secure/file?with?special?chars.html

@ -1,12 +0,0 @@ @@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Special Chars File</title>
</head>
<body>
<p>I'm file?with?special?chars.html</p>
</body>
</html>

7
itest/web/src/test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java

@ -3,11 +3,13 @@ package org.springframework.security.integration; @@ -3,11 +3,13 @@ package org.springframework.security.integration;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.util.StringUtils;
import net.sourceforge.jwebunit.WebTester;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.webapp.WebAppContext;
import javax.servlet.ServletContext;
@ -64,6 +66,11 @@ public abstract class AbstractWebServerIntegrationTests { @@ -64,6 +66,11 @@ public abstract class AbstractWebServerIntegrationTests {
webCtx.getInitParams().put("contextConfigLocation", getContextConfigLocations());
}
ServletHolder servlet = new ServletHolder();
servlet.setName("testapp");
servlet.setClassName(DispatcherServlet.class.getName());
webCtx.addServlet(servlet, "*.htm");
return webCtx;
}

4
itest/web/src/test/java/org/springframework/security/integration/InMemoryProviderWebAppTests.java

@ -42,9 +42,9 @@ public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTes @@ -42,9 +42,9 @@ public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTes
// SEC-1255
@Test
public void redirectToUrlWithSpecialCharsInFilenameWorksOk() throws Exception {
beginAt("secure/file%3Fwith%3Fspecial%3Fchars.html?someArg=1");
beginAt("secure/file%3Fwith%3Fspecial%3Fchars.htm?someArg=1");
login("jimi", "jimispassword");
assertTextPresent("I'm file?with?special?chars.html");
assertTextPresent("I'm file?with?special?chars.htm");
}
}

Loading…
Cancel
Save