use of org.springframework.security.web.util.matcher.RequestMatcher in project perry by ca-cwds.
the class TestLoginServiceValidatorFilter method testLoginUrlMatchesAndInvalidCallback.
@Test
public void testLoginUrlMatchesAndInvalidCallback() throws IOException, ServletException {
LoginServiceValidatorFilter validatorFilter = new LoginServiceValidatorFilter();
RequestMatcher requestMatcher = Mockito.mock(RequestMatcher.class);
validatorFilter.setRequestMatcher(requestMatcher);
HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
HttpServletResponse httpServletResponse = Mockito.mock(HttpServletResponse.class);
Mockito.when(requestMatcher.matches(httpServletRequest)).thenReturn(true);
Mockito.when(httpServletRequest.getRequestURI()).thenReturn("requestUrl");
RequestDispatcher requestDispatcher = Mockito.mock(RequestDispatcher.class);
Mockito.when(httpServletRequest.getRequestDispatcher("/error")).thenReturn(requestDispatcher);
Mockito.when(httpServletRequest.getParameter("callback")).thenReturn("invalidCallbackUrl");
WhiteList whiteList = new WhiteList();
PerryProperties perryProperties = new PerryProperties();
perryProperties.setWhiteList("callbackUrl");
whiteList.setConfiguration(perryProperties);
validatorFilter.setWhiteList(whiteList);
validatorFilter.doFilter(httpServletRequest, httpServletResponse, Mockito.mock(FilterChain.class));
Mockito.verify(requestDispatcher).forward(httpServletRequest, httpServletResponse);
}
use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.
the class EndpointRequestTests method toLinksWhenBasePathEmptyShouldNotMatch.
@Test
void toLinksWhenBasePathEmptyShouldNotMatch() {
RequestMatcher matcher = EndpointRequest.toLinks();
RequestMatcherAssert assertMatcher = assertMatcher(matcher, "");
assertMatcher.doesNotMatch("/actuator/foo");
assertMatcher.doesNotMatch("/actuator/bar");
assertMatcher.doesNotMatch("/");
}
use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.
the class EndpointRequestTests method toLinksShouldOnlyMatchLinks.
@Test
void toLinksShouldOnlyMatchLinks() {
RequestMatcher matcher = EndpointRequest.toLinks();
assertMatcher(matcher).doesNotMatch("/actuator/foo");
assertMatcher(matcher).doesNotMatch("/actuator/bar");
assertMatcher(matcher).matches("/actuator");
assertMatcher(matcher).matches("/actuator/");
}
use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.
the class EndpointRequestTests method toEndpointIdShouldMatchEndpointPath.
@Test
void toEndpointIdShouldMatchEndpointPath() {
RequestMatcher matcher = EndpointRequest.to("foo");
assertMatcher(matcher).matches("/actuator/foo");
}
use of org.springframework.security.web.util.matcher.RequestMatcher in project spring-boot by spring-projects.
the class EndpointRequestTests method linksRequestMatcherShouldUseCustomRequestMatcherProvider.
@Test
void linksRequestMatcherShouldUseCustomRequestMatcherProvider() {
RequestMatcher matcher = EndpointRequest.toLinks();
RequestMatcher mockRequestMatcher = (request) -> false;
RequestMatcherAssert assertMatcher = assertMatcher(matcher, mockPathMappedEndpoints("/actuator"), (pattern) -> mockRequestMatcher);
assertMatcher.doesNotMatch("/actuator");
}
Aggregations