Search in sources :

Example 6 with ActionType

use of org.simbasecurity.api.service.thrift.ActionType 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)

Example 7 with ActionType

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

the class ChainContextImplTest method redirectToPasswordChanged.

@Test
public void redirectToPasswordChanged() {
    when(configurationServiceMock.getValue(PASSWORD_CHANGED_URL)).thenReturn(SIMBA_PASSWORD_CHANGED_URL);
    chainContextImpl.redirectToPasswordChanged();
    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_PASSWORD_CHANGED_URL, actionDescriptor.getRedirectURL());
}
Also used : ActionType(org.simbasecurity.api.service.thrift.ActionType) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) Test(org.junit.Test)

Example 8 with ActionType

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

the class ChainContextImplTest method redirectToChangePasswordWithFilter_alreadyHasToken.

@Test
public void redirectToChangePasswordWithFilter_alreadyHasToken() {
    when(requestDataMock.getRequestURL()).thenReturn(REQUEST_URL);
    String loginToken = "uniqueToken1245698";
    when(requestDataMock.getLoginToken()).thenReturn(loginToken);
    when(requestDataMock.getRequestParameters()).thenReturn(Collections.singletonMap(USERNAME, USERNAME));
    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(1, parameterMap.size());
    assertTrue(parameterMap.containsKey(USERNAME));
}
Also used : ActionType(org.simbasecurity.api.service.thrift.ActionType) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) Test(org.junit.Test)

Example 9 with ActionType

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

the class ChainContextImplTest method redirectWithCredentialError.

@Test
public void redirectWithCredentialError() {
    when(requestDataMock.getRequestURL()).thenReturn(URL_APPLICATION);
    when(requestDataMock.getRequestParameters()).thenReturn(Collections.singletonMap(USERNAME, USERNAME));
    when(requestDataMock.isChangePasswordRequest()).thenReturn(Boolean.FALSE);
    when(requestDataMock.isLoginRequest()).thenReturn(Boolean.TRUE);
    when(configurationServiceMock.getValue(LOGIN_URL)).thenReturn(SIMBA_LOGIN_PAGE_URL);
    LoginMapping loginMapping = new LoginMappingEntity(URL_APPLICATION);
    when(loginMappingServiceMock.createMapping(URL_APPLICATION)).thenReturn(loginMapping);
    chainContextImpl.redirectWithCredentialError(LOGIN_FAILED);
    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(3, parameterMap.size());
    assertTrue(parameterMap.containsKey(USERNAME));
    assertTrue(parameterMap.containsKey(ERROR_MESSAGE));
    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 ActionType

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

the class SimbaJAXWSHandlerTest method soapAuthenticationSuccessful.

@Test
@Ignore
public // TODO: Create integration test
void soapAuthenticationSuccessful() throws Exception {
    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");
    // when(simbaServiceMock.processRequest(getChainConfiguration())).thenReturn(actionDescriptor);
    handler.handleMessage(messageContextMock);
    verify(messageContextMock).put(SimbaPrincipal.SIMBA_USER_CTX_KEY, "principal");
}
Also used : ActionType(org.simbasecurity.api.service.thrift.ActionType) ActionDescriptor(org.simbasecurity.api.service.thrift.ActionDescriptor) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ActionType (org.simbasecurity.api.service.thrift.ActionType)11 Test (org.junit.Test)10 ActionDescriptor (org.simbasecurity.api.service.thrift.ActionDescriptor)10 LoginMapping (org.simbasecurity.core.domain.LoginMapping)4 LoginMappingEntity (org.simbasecurity.core.domain.LoginMappingEntity)4 FilterChain (javax.servlet.FilterChain)2 ArrayList (java.util.ArrayList)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Ignore (org.junit.Ignore)1 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)1 HttpServletRequestWithPrincipal (org.simbasecurity.client.filter.request.HttpServletRequestWithPrincipal)1