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

This commit is contained in:
Luke Taylor 2009-10-11 15:24:17 +00:00
parent 881632cc08
commit c9e2121504
6 changed files with 33 additions and 24 deletions

View File

@ -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 @@
<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>

View File

@ -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");
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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 {
webCtx.getInitParams().put("contextConfigLocation", getContextConfigLocations());
}
ServletHolder servlet = new ServletHolder();
servlet.setName("testapp");
servlet.setClassName(DispatcherServlet.class.getName());
webCtx.addServlet(servlet, "*.htm");
return webCtx;
}

View File

@ -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");
}
}