SEC-2129: AntPathRequestMatcher also supports case sensitive comparisions

This commit is contained in:
Rob Winch
2013-08-25 16:26:18 -05:00
parent 7d1d856729
commit 33db440961
2 changed files with 54 additions and 10 deletions

View File

@@ -12,6 +12,7 @@
*/
package org.springframework.security.web.util;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -112,6 +113,17 @@ public class AntPathRequestMatcherTests {
assertFalse(matcher.matches(request));
}
@Test
public void caseSensitive() throws Exception {
MockHttpServletRequest request = createRequest("/UPPER");
assertThat(new AntPathRequestMatcher("/upper",null,true).matches(request)).isFalse();
assertThat(new AntPathRequestMatcher("/upper","POST",true).matches(request)).isFalse();
assertThat(new AntPathRequestMatcher("/upper","GET",true).matches(request)).isFalse();
assertThat(new AntPathRequestMatcher("/upper",null,false).matches(request)).isTrue();
assertThat(new AntPathRequestMatcher("/upper","POST",false).matches(request)).isTrue();
}
@Test
public void equalsBehavesCorrectly() throws Exception {
// Both universal wildcard options should be equal
@@ -121,6 +133,7 @@ public class AntPathRequestMatcherTests {
assertFalse(new AntPathRequestMatcher("/xyz", "POST").equals(new AntPathRequestMatcher("/xyz", "GET")));
assertFalse(new AntPathRequestMatcher("/xyz").equals(new AntPathRequestMatcher("/xxx")));
assertFalse(new AntPathRequestMatcher("/xyz").equals(new AnyRequestMatcher()));
assertFalse(new AntPathRequestMatcher("/xyz","GET", false).equals(new AntPathRequestMatcher("/xyz","GET", true)));
}
@Test