Search in sources :

Example 6 with ActionDescriptor

use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.

the class DoFilterAndSetPrincipalActionTest method testExecute_withPrincipal.

@Test
public void testExecute_withPrincipal() throws Exception {
    FilterChain filterChain = mock(FilterChain.class);
    ActionDescriptor actionDescriptor = new ActionDescriptor(new HashSet<ActionType>(), new HashMap<String, String>(), null, null, null, null);
    actionDescriptor.getActionTypes().add(ActionType.DO_FILTER_AND_SET_PRINCIPAL);
    actionDescriptor.setPrincipal("principal");
    DoFilterAndSetPrincipalAction action = new DoFilterAndSetPrincipalAction(actionDescriptor);
    action.setRequest(request);
    action.setResponse(response);
    action.setFilterChain(filterChain);
    action.execute();
    verify(filterChain).doFilter(any(HttpServletRequestWithPrincipal.class), any(HttpServletResponse.class));
}
Also used : ActionType(org.simbasecurity.api.service.thrift.ActionType) FilterChain(javax.servlet.FilterChain) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestWithPrincipal(org.simbasecurity.client.filter.request.HttpServletRequestWithPrincipal) Test(org.junit.Test)

Example 7 with ActionDescriptor

use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.

the class SimbaJAXWSHandlerTest method soapAuthenticationThrowsExceptionWhenUnsuccessful.

@Test(expected = SimbaWSAuthenticationException.class)
@Ignore
public // TODO: Create integration test
void soapAuthenticationThrowsExceptionWhenUnsuccessful() throws Exception {
    ActionDescriptor actionDescriptor = new ActionDescriptor();
    // when(simbaServiceMock.processRequest(getChainConfiguration())).thenReturn(actionDescriptor);
    handler.handleMessage(messageContextMock);
}
Also used : ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with ActionDescriptor

use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.

the class ChainContextImplTest method redirectToChangePasswordWithFilter_noToken.

@Test
public void redirectToChangePasswordWithFilter_noToken() {
    when(requestDataMock.getRequestURL()).thenReturn(URL_APPLICATION);
    when(requestDataMock.getLoginToken()).thenReturn(null);
    when(requestDataMock.getRequestParameters()).thenReturn(Collections.singletonMap(USERNAME, USERNAME));
    LoginMapping loginMapping = new LoginMappingEntity(URL_APPLICATION);
    when(loginMappingServiceMock.createMapping(URL_APPLICATION)).thenReturn(loginMapping);
    chainContextImpl.redirectToChangePasswordWithFilter();
    ActionDescriptor actionDescriptor = chainContextImpl.getActionDescriptor();
    Set<ActionType> actionTypes = actionDescriptor.getActionTypes();
    assertEquals(2, actionTypes.size());
    assertTrue(actionTypes.contains(ADD_PARAMETER_TO_TARGET));
    assertTrue(actionTypes.contains(REDIRECT));
    assertEquals(SIMBA_WEB_URL + SIMBA_CHANGEPASSWORD_PAGE_URL, actionDescriptor.getRedirectURL());
    Map<String, String> parameterMap = actionDescriptor.getParameterMap();
    assertEquals(2, parameterMap.size());
    assertTrue(parameterMap.containsKey(USERNAME));
    assertTrue(parameterMap.containsKey(LOGIN_TOKEN));
    Mockito.verify(loginMappingServiceMock).createMapping(URL_APPLICATION);
}
Also used : ActionType(org.simbasecurity.api.service.thrift.ActionType) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) LoginMappingEntity(org.simbasecurity.core.domain.LoginMappingEntity) LoginMapping(org.simbasecurity.core.domain.LoginMapping) Test(org.junit.Test)

Example 9 with ActionDescriptor

use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.

the class ChainContextImplTest method redirectToLogin.

@Test
public void redirectToLogin() {
    when(requestDataMock.getRequestURL()).thenReturn(URL_APPLICATION);
    when(requestDataMock.getRequestParameters()).thenReturn(Collections.singletonMap(USERNAME, USERNAME));
    LoginMapping loginMapping = new LoginMappingEntity(URL_APPLICATION);
    when(loginMappingServiceMock.createMapping(URL_APPLICATION)).thenReturn(loginMapping);
    chainContextImpl.redirectToLogin();
    ActionDescriptor actionDescriptor = chainContextImpl.getActionDescriptor();
    Set<ActionType> actionTypes = actionDescriptor.getActionTypes();
    assertEquals(2, actionTypes.size());
    assertTrue(actionTypes.contains(ADD_PARAMETER_TO_TARGET));
    assertTrue(actionTypes.contains(REDIRECT));
    assertEquals(SIMBA_WEB_URL + SIMBA_LOGIN_PAGE_URL, actionDescriptor.getRedirectURL());
    Map<String, String> parameterMap = actionDescriptor.getParameterMap();
    assertEquals(1, parameterMap.size());
    assertTrue(parameterMap.containsKey(LOGIN_TOKEN));
    Mockito.verify(loginMappingServiceMock).createMapping(URL_APPLICATION);
}
Also used : ActionType(org.simbasecurity.api.service.thrift.ActionType) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) LoginMappingEntity(org.simbasecurity.core.domain.LoginMappingEntity) LoginMapping(org.simbasecurity.core.domain.LoginMapping) Test(org.junit.Test)

Example 10 with ActionDescriptor

use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.

the class ChainContextImplTest method redirectToChangePasswordDirect_userIsInTheApplication_ClicksChangePwd.

@Test
public void redirectToChangePasswordDirect_userIsInTheApplication_ClicksChangePwd() {
    when(requestDataMock.getRequestURL()).thenReturn(URL_APPLICATION);
    SSOToken ssoToken = new SSOToken();
    when(requestDataMock.getSsoToken()).thenReturn(ssoToken);
    LoginMapping loginMapping = new LoginMappingEntity(URL_APPLICATION);
    when(loginMappingServiceMock.createMapping(URL_APPLICATION)).thenReturn(loginMapping);
    chainContextImpl.redirectToChangePasswordDirect();
    ActionDescriptor actionDescriptor = chainContextImpl.getActionDescriptor();
    Set<ActionType> actionTypes = actionDescriptor.getActionTypes();
    assertEquals(2, actionTypes.size());
    assertTrue(actionTypes.contains(ADD_PARAMETER_TO_TARGET));
    assertTrue(actionTypes.contains(REDIRECT));
    assertEquals(SIMBA_WEB_URL + SIMBA_CHANGEPASSWORD_PAGE_URL, actionDescriptor.getRedirectURL());
    Map<String, String> parameterMap = actionDescriptor.getParameterMap();
    assertEquals(3, parameterMap.size());
    assertTrue(parameterMap.containsKey(USERNAME));
    assertTrue(parameterMap.containsKey(SIMBA_SSO_TOKEN));
    assertTrue(parameterMap.containsKey(LOGIN_TOKEN));
    Mockito.verify(loginMappingServiceMock).createMapping(URL_APPLICATION);
}
Also used : SSOToken(org.simbasecurity.api.service.thrift.SSOToken) ActionType(org.simbasecurity.api.service.thrift.ActionType) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) LoginMappingEntity(org.simbasecurity.core.domain.LoginMappingEntity) LoginMapping(org.simbasecurity.core.domain.LoginMapping) Test(org.junit.Test)

Aggregations

ActionDescriptor (org.simbasecurity.api.service.thrift.ActionDescriptor)32 Test (org.junit.Test)23 RequestData (org.simbasecurity.api.service.thrift.RequestData)14 THttpClient (org.apache.thrift.transport.THttpClient)10 ActionType (org.simbasecurity.api.service.thrift.ActionType)10 Client (org.simbasecurity.api.service.thrift.AuthenticationFilterService.Client)7 SimbaCredentials (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials)7 ActionDescriptorBuilderForTests (org.simbasecurity.dwclient.test.stub.simba.ActionDescriptorBuilderForTests)7 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)5 ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)4 AuthenticationFilterService (org.simbasecurity.api.service.thrift.AuthenticationFilterService)4 LoginMapping (org.simbasecurity.core.domain.LoginMapping)4 LoginMappingEntity (org.simbasecurity.core.domain.LoginMappingEntity)4 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)3 TProtocol (org.apache.thrift.protocol.TProtocol)3 SimbaPrincipal (org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal)3 IOException (java.io.IOException)2 FilterChain (javax.servlet.FilterChain)2 Cookie (javax.servlet.http.Cookie)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2