Search in sources :

Example 31 with ActionDescriptor

use of org.simbasecurity.api.service.thrift.ActionDescriptor 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 32 with ActionDescriptor

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

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