Search in sources :

Example 16 with SimbaCredentials

use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials in project simba-os by cegeka.

the class SimbaAuthRule method before.

protected void before(ResourceTest currentTest) throws AuthenticationException {
    SimbaAuthenticator authenticatorMock = mock(SimbaAuthenticator.class);
    SimbaCredentialsFactory simbaCredentialsFactoryMock = mock(SimbaCredentialsFactory.class);
    SimbaAuthenticatedProvider simbaAuthenticatedProvider = new SimbaAuthenticatedProvider(authenticatorMock, simbaCredentialsFactoryMock, domainProvider);
    SimbaCredentials simbaCredentials = new SimbaCredentialsBuilderForTests().build();
    when(simbaCredentialsFactoryMock.create(any(ContainerRequest.class))).thenReturn(simbaCredentials);
    when(authenticatorMock.authenticate(simbaCredentials)).thenReturn(Optional.fromNullable(new SimbaPrincipal("user", "ssoToken")));
    currentTest.addProvider(simbaAuthenticatedProvider);
}
Also used : SimbaPrincipal(org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal) SimbaAuthenticator(org.simbasecurity.dwclient.dropwizard.authenticator.SimbaAuthenticator) SimbaCredentials(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials) SimbaCredentialsBuilderForTests(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsBuilderForTests) SimbaAuthenticatedProvider(org.simbasecurity.dwclient.dropwizard.provider.SimbaAuthenticatedProvider) SimbaCredentialsFactory(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory) ContainerRequest(com.sun.jersey.spi.container.ContainerRequest)

Aggregations

SimbaCredentials (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials)16 Test (org.junit.Test)13 THttpClient (org.apache.thrift.transport.THttpClient)11 Client (org.simbasecurity.api.service.thrift.AuthenticationFilterService.Client)11 RequestData (org.simbasecurity.api.service.thrift.RequestData)11 ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)7 ActionDescriptor (org.simbasecurity.api.service.thrift.ActionDescriptor)7 ActionDescriptorBuilderForTests (org.simbasecurity.dwclient.test.stub.simba.ActionDescriptorBuilderForTests)7 SimbaPrincipal (org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal)5 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)4 AuthenticationException (com.yammer.dropwizard.auth.AuthenticationException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 TException (org.apache.thrift.TException)1 SimbaAuthenticator (org.simbasecurity.dwclient.dropwizard.authenticator.SimbaAuthenticator)1 SimbaCredentialsBuilderForTests (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsBuilderForTests)1 SimbaCredentialsFactory (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory)1 SimbaAuthenticatedProvider (org.simbasecurity.dwclient.dropwizard.provider.SimbaAuthenticatedProvider)1 SimbaUnavailableException (org.simbasecurity.dwclient.exception.SimbaUnavailableException)1