use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials 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.dwclient.dropwizard.credentials.SimbaCredentials 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.dwclient.dropwizard.credentials.SimbaCredentials in project simba-os by cegeka.
the class SimbaAuthenticatorTest method authenticate_WhenConnectionToSimbaFails_ThrowAuthenticationException.
@Test
public void authenticate_WhenConnectionToSimbaFails_ThrowAuthenticationException() throws Exception {
SimbaCredentials credentials = mock(SimbaCredentials.class);
when(simbaGatewayMock.authenticate(credentials)).thenThrow(new SimbaUnavailableException());
expectedException.expect(AuthenticationException.class);
authenticator.authenticate(credentials);
}
use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials 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());
}
use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials in project simba-os by cegeka.
the class SimbaGatewayTest method authenticate_WhenClientIsABrowser_ExecuteBrowserLoginChain.
@Test
public void authenticate_WhenClientIsABrowser_ExecuteBrowserLoginChain() throws Exception {
SimbaCredentials credentials = mock(SimbaCredentials.class);
when(credentials.isClientABrowser()).thenReturn(true);
Client authenticationServiceMock = setupSimbaServiceToReturnASimbaAuthenticationService();
simbaGateway.authenticate(credentials);
verify(authenticationServiceMock).processRequest(any(RequestData.class), eq(SimbaGateway.SESSION_AUTHENTICATE_CHAIN));
}
Aggregations