use of gov.ca.cwds.service.WhiteList in project perry by ca-cwds.
the class TestLoginServiceValidatorFilter method testLoginUrlNotMatchesAndInvalidCallback.
@Test
public void testLoginUrlNotMatchesAndInvalidCallback() 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(false);
Mockito.when(httpServletRequest.getRequestURI()).thenReturn("requestUrl");
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));
}
use of gov.ca.cwds.service.WhiteList in project perry by ca-cwds.
the class TestLoginServiceValidatorFilter method testLoginUrlMatchesAndValidCallback.
@Test
public void testLoginUrlMatchesAndValidCallback() 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");
Mockito.when(httpServletRequest.getParameter("callback")).thenReturn("callbackUrl");
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));
}
use of gov.ca.cwds.service.WhiteList 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);
}
Aggregations