Remove duplicate test.

Remove duplicate test with `trailingWildcardWithVariableMatchesCorrectly()`.

Fixes gh-183
This commit is contained in:
izeye 2015-03-24 09:19:29 +09:00 committed by Rob Winch
parent 4fd9fd2939
commit 2c85fb05d0
1 changed files with 31 additions and 39 deletions

View File

@ -16,17 +16,18 @@
package org.springframework.security.web.util.matcher; package org.springframework.security.web.util.matcher;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
/** /**
* @author Luke Taylor * @author Luke Taylor
* @author Rob Winch * @author Rob Winch
@ -71,15 +72,6 @@ public class AntPathRequestMatcherTests {
assertThat(matcher.matches(createRequest("/blah/blah"))).isTrue(); assertThat(matcher.matches(createRequest("/blah/blah"))).isTrue();
assertThat(matcher.matches(createRequest("/blah/bleh"))).isFalse(); assertThat(matcher.matches(createRequest("/blah/bleh"))).isFalse();
assertThat(matcher.matches(createRequest("/blah/aaa/blah/bbb"))).isTrue(); assertThat(matcher.matches(createRequest("/blah/aaa/blah/bbb"))).isTrue();
matcher = new AntPathRequestMatcher("/{id}/blAh/**");
assertThat(matcher.matches(createRequest("/1234/blah"))).isTrue();
assertThat(matcher.matches(createRequest("/4567/bleh"))).isFalse();
assertThat(matcher.matches(createRequest("/paskos/blah/"))).isTrue();
assertThat(matcher.matches(createRequest("/12345/blah/xxx"))).isTrue();
assertThat(matcher.matches(createRequest("/12345/blaha"))).isFalse();
assertThat(matcher.matches(createRequest("/paskos/bleh/"))).isFalse();
} }
@Test @Test
@ -157,36 +149,36 @@ public class AntPathRequestMatcherTests {
@Test @Test
public void caseSensitive() throws Exception { public void caseSensitive() throws Exception {
MockHttpServletRequest request = createRequest("/UPPER"); MockHttpServletRequest request = createRequest("/UPPER");
assertThat(new AntPathRequestMatcher("/upper", null, true).matches( assertThat(new AntPathRequestMatcher("/upper", null, true).matches(request))
request)).isFalse(); .isFalse();
assertThat(new AntPathRequestMatcher("/upper", "POST", true).matches( assertThat(new AntPathRequestMatcher("/upper", "POST", true).matches(request))
request)).isFalse(); .isFalse();
assertThat(new AntPathRequestMatcher("/upper", "GET", true).matches( assertThat(new AntPathRequestMatcher("/upper", "GET", true).matches(request))
request)).isFalse(); .isFalse();
assertThat(new AntPathRequestMatcher("/upper", null, false).matches( assertThat(new AntPathRequestMatcher("/upper", null, false).matches(request))
request)).isTrue(); .isTrue();
assertThat(new AntPathRequestMatcher("/upper", "POST", false).matches( assertThat(new AntPathRequestMatcher("/upper", "POST", false).matches(request))
request)).isTrue(); .isTrue();
} }
@Test @Test
public void equalsBehavesCorrectly() throws Exception { public void equalsBehavesCorrectly() throws Exception {
// Both universal wildcard options should be equal // Both universal wildcard options should be equal
assertThat(new AntPathRequestMatcher("**")).isEqualTo( assertThat(new AntPathRequestMatcher("**"))
new AntPathRequestMatcher("/**")); .isEqualTo(new AntPathRequestMatcher("/**"));
assertThat(new AntPathRequestMatcher("/xyz")).isEqualTo( assertThat(new AntPathRequestMatcher("/xyz"))
new AntPathRequestMatcher("/xyz")); .isEqualTo(new AntPathRequestMatcher("/xyz"));
assertThat(new AntPathRequestMatcher("/xyz", "POST")).isEqualTo( assertThat(new AntPathRequestMatcher("/xyz", "POST"))
new AntPathRequestMatcher("/xyz", "POST")); .isEqualTo(new AntPathRequestMatcher("/xyz", "POST"));
assertThat(new AntPathRequestMatcher("/xyz", "POST")).isNotEqualTo( assertThat(new AntPathRequestMatcher("/xyz", "POST"))
new AntPathRequestMatcher("/xyz", "GET")); .isNotEqualTo(new AntPathRequestMatcher("/xyz", "GET"));
assertThat(new AntPathRequestMatcher("/xyz")).isNotEqualTo( assertThat(new AntPathRequestMatcher("/xyz"))
new AntPathRequestMatcher("/xxx")); .isNotEqualTo(new AntPathRequestMatcher("/xxx"));
assertThat(new AntPathRequestMatcher("/xyz").equals( assertThat(new AntPathRequestMatcher("/xyz").equals(AnyRequestMatcher.INSTANCE))
AnyRequestMatcher.INSTANCE)).isFalse(); .isFalse();
assertThat(new AntPathRequestMatcher("/xyz", "GET", false)).isNotEqualTo( assertThat(new AntPathRequestMatcher("/xyz", "GET", false))
new AntPathRequestMatcher("/xyz", "GET", true)); .isNotEqualTo(new AntPathRequestMatcher("/xyz", "GET", true));
} }
@Test @Test
@ -206,9 +198,9 @@ public class AntPathRequestMatcherTests {
} }
private HttpServletRequest createRequestWithNullMethod(String path) { private HttpServletRequest createRequestWithNullMethod(String path) {
when(request.getQueryString()).thenReturn("doesntMatter"); when(this.request.getQueryString()).thenReturn("doesntMatter");
when(request.getServletPath()).thenReturn(path); when(this.request.getServletPath()).thenReturn(path);
return request; return this.request;
} }
private MockHttpServletRequest createRequest(String path) { private MockHttpServletRequest createRequest(String path) {