use of org.simbasecurity.api.service.thrift.RequestData in project simba-os by cegeka.
the class SimbaGatewayTest method login_WhenActionDescriptorActionTypesIsEmpty_ThenReturnsEmptySSOToken.
@Test
public void login_WhenActionDescriptorActionTypesIsEmpty_ThenReturnsEmptySSOToken() throws Exception {
Client authenticationServicemock = setupSimbaServiceToReturnASimbaAuthenticationService();
ContainerRequest containerRequestMock = mock(ContainerRequest.class);
SimbaCredentials simbaCredentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
ActionDescriptor actionDescriptor = new ActionDescriptorBuilderForTests().withActionTypes().build();
when(simbaCredentialsFactoryMock.create(containerRequestMock, false)).thenReturn(simbaCredentials);
when(simbaCredentials.asRequestData()).thenReturn(requestData);
when(authenticationServicemock.processRequest(requestData, LOGIN_AUTHENTICATE_CHAIN)).thenReturn(actionDescriptor);
Optional<String> ssoToken = simbaGateway.login(containerRequestMock);
assertThat(ssoToken.isPresent()).isFalse();
}
use of org.simbasecurity.api.service.thrift.RequestData in project simba-os by cegeka.
the class SimbaGatewayTest method login_WhenActionDescriptorActionTypesIsNull_ThenReturnsEmptySSOToken.
@Test
public void login_WhenActionDescriptorActionTypesIsNull_ThenReturnsEmptySSOToken() throws Exception {
Client authenticationServicemock = setupSimbaServiceToReturnASimbaAuthenticationService();
ContainerRequest containerRequestMock = mock(ContainerRequest.class);
SimbaCredentials simbaCredentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
ActionDescriptor actionDescriptor = new ActionDescriptorBuilderForTests().build();
when(simbaCredentialsFactoryMock.create(containerRequestMock, false)).thenReturn(simbaCredentials);
when(simbaCredentials.asRequestData()).thenReturn(requestData);
when(authenticationServicemock.processRequest(requestData, LOGIN_AUTHENTICATE_CHAIN)).thenReturn(actionDescriptor);
Optional<String> ssoToken = simbaGateway.login(containerRequestMock);
assertThat(ssoToken.isPresent()).isFalse();
}
use of org.simbasecurity.api.service.thrift.RequestData in project simba-os by cegeka.
the class SimbaGatewayTest method authenticate_WhenAuthenticationCallWentWrong_ThrowsSimbaUnavailableException.
@Test
public void authenticate_WhenAuthenticationCallWentWrong_ThrowsSimbaUnavailableException() throws Exception {
SimbaCredentials credentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
when(credentials.asRequestData()).thenReturn(requestData);
Client authenticationServiceMock = setupSimbaServiceToReturnASimbaAuthenticationService();
when(authenticationServiceMock.processRequest(requestData, SESSION_AUTHENTICATE_CHAIN)).thenThrow(new TException());
expectedException.expect(SimbaUnavailableException.class);
simbaGateway.authenticate(credentials);
}
use of org.simbasecurity.api.service.thrift.RequestData in project simba-os by cegeka.
the class SimbaGatewayTest method login_WhenActionDescriptorMissesMAKECOOKIE_ReturnsEmptySSOToken.
@Test
public void login_WhenActionDescriptorMissesMAKECOOKIE_ReturnsEmptySSOToken() throws Exception {
Client authenticationServicemock = setupSimbaServiceToReturnASimbaAuthenticationService();
ContainerRequest containerRequestMock = mock(ContainerRequest.class);
SimbaCredentials simbaCredentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
ActionDescriptor actionDescriptor = new ActionDescriptorBuilderForTests().withActionTypes(ActionType.REDIRECT).build();
when(simbaCredentialsFactoryMock.create(containerRequestMock, false)).thenReturn(simbaCredentials);
when(simbaCredentials.asRequestData()).thenReturn(requestData);
when(authenticationServicemock.processRequest(requestData, LOGIN_AUTHENTICATE_CHAIN)).thenReturn(actionDescriptor);
Optional<String> ssoToken = simbaGateway.login(containerRequestMock);
assertThat(ssoToken.isPresent()).isFalse();
}
use of org.simbasecurity.api.service.thrift.RequestData in project simba-os by cegeka.
the class SimbaGatewayTest method login.
@Test
public void login() throws Exception {
Client authenticationServicemock = setupSimbaServiceToReturnASimbaAuthenticationService();
ContainerRequest containerRequestMock = mock(ContainerRequest.class);
SimbaCredentials simbaCredentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
SSOToken expectedSSOToken = new SSOToken("token");
ActionDescriptor actionDescriptor = new ActionDescriptorBuilderForTests().withActionTypes(ActionType.MAKE_COOKIE).withSsoToken(expectedSSOToken).build();
when(simbaCredentialsFactoryMock.create(containerRequestMock, false)).thenReturn(simbaCredentials);
when(simbaCredentials.asRequestData()).thenReturn(requestData);
when(authenticationServicemock.processRequest(requestData, LOGIN_AUTHENTICATE_CHAIN)).thenReturn(actionDescriptor);
Optional<String> actualSSOToken = simbaGateway.login(containerRequestMock);
assertThat(actualSSOToken.isPresent()).isTrue();
assertThat(actualSSOToken.get()).isEqualTo(expectedSSOToken.getToken());
}
Aggregations