use of gov.ca.cwds.PerryProperties in project perry by ca-cwds.
the class TestDevAuthenticationProvider method before.
@Before
public void before() {
authenticationProvider = new DevAuthenticationProvider();
authenticationProvider.perryProperties = new PerryProperties();
}
use of gov.ca.cwds.PerryProperties 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.PerryProperties 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.PerryProperties 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 gov.ca.cwds.PerryProperties in project perry by ca-cwds.
the class IdentityMappingServiceTest method test.
@Test
public void test() {
IdentityMappingService identityMappingService = new IdentityMappingService();
PerryProperties configuration = new PerryProperties();
identityMappingService.setConfiguration(configuration);
UniversalUserToken universalUserToken = new UniversalUserToken();
universalUserToken.setUserId("user");
String user = identityMappingService.map(universalUserToken, "test");
assert user.equals("user");
}
Aggregations