SEC-1235: Added test to attempt to verify (failed to reproduce).

This commit is contained in:
Luke Taylor 2009-09-05 14:14:12 +00:00
parent 8632946f30
commit d099d14e9b
2 changed files with 24 additions and 2 deletions

View File

@ -17,8 +17,7 @@ package org.springframework.security.config;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.*;
import java.util.List;
@ -53,6 +52,8 @@ public class FilterChainProxyConfigTests {
@Before
public void loadContext() {
System.setProperty("sec1235.pattern1", "/login");
System.setProperty("sec1235.pattern2", "/logout");
appCtx = new ClassPathXmlApplicationContext("org/springframework/security/util/filtertest-valid.xml");
}
@ -113,6 +114,17 @@ public class FilterChainProxyConfigTests {
assertNull(filterChainProxy.getFilters(url));
}
// SEC-1235
@Test
public void mixingPatternsAndPlaceholdersDoesntCauseOrderingIssues() throws Exception {
FilterChainProxy filterChainProxy = (FilterChainProxy) appCtx.getBean("sec1235FilterChainProxy", FilterChainProxy.class);
String[] paths = filterChainProxy.getFilterChainMap().keySet().toArray(new String[0]);
assertEquals("/login*", paths[0]);
assertEquals("/logout", paths[1]);
assertEquals("/**", paths[2]);
}
private void checkPathAndFilterOrder(FilterChainProxy filterChainProxy) throws Exception {
List<Filter> filters = filterChainProxy.getFilters("/foo/blah");
assertEquals(1, filters.size());

View File

@ -89,6 +89,16 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc
</sec:filter-chain-map>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
<bean id="sec1235FilterChainProxy" class="org.springframework.security.web.FilterChainProxy">
<sec:filter-chain-map path-type="ant">
<sec:filter-chain pattern="${sec1235.pattern1}*" filters="sif,apf,mockFilter"/>
<sec:filter-chain pattern="${sec1235.pattern2}" filters="mockFilter2"/>
<sec:filter-chain pattern="/**" filters="sif"/>
</sec:filter-chain-map>
</bean>
<bean id="newFilterChainProxyNonNamespace" class="org.springframework.security.web.FilterChainProxy">
<property name="matcher">
<bean class="org.springframework.security.web.util.AntUrlPathMatcher"/>