Ensure path starts with "/" in ErrorController

When mapping the ErrorController path to Spring Security it's
important that it starts with "/". This change ensures that is
the case even if the user has omitted the leading "/".

Fixes gh-694
This commit is contained in:
Dave Syer
2014-04-19 19:21:45 -07:00
parent 506e57663a
commit 00b85e8c42
2 changed files with 17 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import static org.junit.Assert.assertEquals;
@@ -79,6 +80,12 @@ public class ManagementSecurityAutoConfigurationTests {
.size());
}
@Test
public void testPathNormalization() throws Exception {
String path = "admin/./error";
assertEquals("admin/error", StringUtils.cleanPath(path));
}
@Test
public void testWebConfigurationWithExtraRole() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();