use of org.springframework.security.web.util.matcher.ELRequestMatcher in project spring-security by spring-projects.
the class ELRequestMatcherTests method testHasIpAddressFalse.
@Test
public void testHasIpAddressFalse() throws Exception {
ELRequestMatcher requestMatcher = new ELRequestMatcher("hasIpAddress('1.1.1.1')");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("1.1.1.2");
assertThat(requestMatcher.matches(request)).isFalse();
}
use of org.springframework.security.web.util.matcher.ELRequestMatcher in project spring-security by spring-projects.
the class ELRequestMatcherTests method testHasHeaderFalse.
@Test
public void testHasHeaderFalse() throws Exception {
ELRequestMatcher requestMatcher = new ELRequestMatcher("hasHeader('User-Agent','MSIE')");
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("User-Agent", "wrong");
assertThat(requestMatcher.matches(request)).isFalse();
}
use of org.springframework.security.web.util.matcher.ELRequestMatcher in project spring-security by spring-projects.
the class ELRequestMatcherTests method testHasHeaderTrue.
@Test
public void testHasHeaderTrue() throws Exception {
ELRequestMatcher requestMatcher = new ELRequestMatcher("hasHeader('User-Agent','MSIE')");
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("User-Agent", "MSIE");
assertThat(requestMatcher.matches(request)).isTrue();
}
use of org.springframework.security.web.util.matcher.ELRequestMatcher in project spring-security by spring-projects.
the class ELRequestMatcherTests method testHasIpAddressTrue.
@Test
public void testHasIpAddressTrue() throws Exception {
ELRequestMatcher requestMatcher = new ELRequestMatcher("hasIpAddress('1.1.1.1')");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("1.1.1.1");
assertThat(requestMatcher.matches(request)).isTrue();
}
use of org.springframework.security.web.util.matcher.ELRequestMatcher in project spring-security by spring-projects.
the class ELRequestMatcherTests method testHasHeaderTwoEntries.
@Test
public void testHasHeaderTwoEntries() throws Exception {
ELRequestMatcher requestMatcher = new ELRequestMatcher("hasHeader('User-Agent','MSIE') or hasHeader('User-Agent','Mozilla')");
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("User-Agent", "MSIE");
assertThat(requestMatcher.matches(request)).isTrue();
request = new MockHttpServletRequest();
request.addHeader("User-Agent", "Mozilla");
assertThat(requestMatcher.matches(request)).isTrue();
}
Aggregations