use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal in project simba-os by cegeka.
the class SimbaAuthenticatorTest method authenticate_WhenAuthenticationIsSuccessful_ReturnPrincipal.
@Test
public void authenticate_WhenAuthenticationIsSuccessful_ReturnPrincipal() throws Exception {
SimbaCredentials credentials = mock(SimbaCredentials.class);
Optional<SimbaPrincipal> expected = Optional.of(new SimbaPrincipal("username", "token"));
when(simbaGatewayMock.authenticate(credentials)).thenReturn(expected);
Optional<SimbaPrincipal> actual = authenticator.authenticate(credentials);
assertThat(actual).isEqualTo(expected);
}
use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal in project simba-os by cegeka.
the class SimbaAuthenticatedInjectableTest method getValue_WhenAuthenticatorReturnsPresentPrincipal_ThenDomainProviderIsCalledToLookupDomainPrincipalWithPrincipal.
@Test
public void getValue_WhenAuthenticatorReturnsPresentPrincipal_ThenDomainProviderIsCalledToLookupDomainPrincipalWithPrincipal() throws Exception {
SimbaPrincipal principal = new SimbaPrincipal("user", "token");
when(authenticatorMock.authenticate(simbaCredentials)).thenReturn(Optional.of(principal));
AuthenticatedPrincipal expectedDomainPrincipal = mock(AuthenticatedPrincipal.class);
when(domainProviderMock.lookUp(principal)).thenReturn(expectedDomainPrincipal);
AuthenticatedPrincipal actualDomainPrincipal = injectable.getValue(dummyHttpContext);
assertThat(actualDomainPrincipal).isEqualTo(expectedDomainPrincipal);
}
use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal 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);
}
Aggregations