use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory in project simba-os by cegeka.
the class SimbaManagerRule method before.
private void before() throws IOException, ConfigurationException, SimbaUnavailableException {
SimbaManagerRestConfiguration simbaRestMgrConfig = getSimbaManagerRestConfiguration();
simbaWebResource = getSimbaWebResource(simbaRestMgrConfig);
String simbaWebURL = simbaRestMgrConfig.getSimbaWebURL();
SimbaGateway simbaGateway = new SimbaGateway(simbaWebURL, new SimbaServiceFactory(), new SimbaCredentialsFactory(simbaWebURL));
String appUser = simbaRestMgrConfig.getAppUser();
String appPassword = simbaRestMgrConfig.getAppPassword();
ssoToken = simbaGateway.login(appUser, appPassword);
if (!ssoToken.isPresent()) {
fail(String.format("Unsuccessful login for configured user/password: %s/%s", appUser, appPassword));
}
}
use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory 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