use of io.gravitee.am.repository.exceptions.TechnicalException in project gravitee-access-management by gravitee-io.
the class AuthenticationRequestAcknowledgeHandlerTest method shouldNotGenerateAuthReqId_RegistrationFailure.
@Test
public void shouldNotGenerateAuthReqId_RegistrationFailure() throws Exception {
CibaAuthenticationRequest cibaRequest = new CibaAuthenticationRequest();
cibaRequest.setLoginHint("username");
cibaRequest.setSubject("usernameuuid");
router.route().order(-1).handler(routingContext -> {
routingContext.put(ConstantKeys.CLIENT_CONTEXT_KEY, client);
routingContext.put(ConstantKeys.CIBA_AUTH_REQUEST_KEY, cibaRequest);
routingContext.next();
});
when(jwtService.encode(any(JWT.class), any(Client.class))).thenReturn(Single.just("signed_jwt"));
when(authReqService.register(any(), any())).thenReturn(Single.error(new TechnicalException()));
testRequest(HttpMethod.POST, CIBAProvider.CIBA_PATH + CIBAProvider.AUTHENTICATION_ENDPOINT + "?request=fakejwt", null, HttpStatusCode.INTERNAL_SERVER_ERROR_500, "Internal Server Error", null);
verify(authReqService).register(any(), any());
verify(authReqService, never()).updateAuthDeviceInformation(any());
verify(notifier, never()).notify(any());
}
use of io.gravitee.am.repository.exceptions.TechnicalException in project gravitee-access-management by gravitee-io.
the class InstallationCommandHandlerTest method handleWithException.
@Test
public void handleWithException() {
final Installation installation = new Installation();
installation.setId(INSTALLATION_ID);
installation.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
InstallationPayload installationPayload = new InstallationPayload();
InstallationCommand command = new InstallationCommand(installationPayload);
installationPayload.setId(INSTALLATION_ID);
installationPayload.setStatus("ACCEPTED");
when(installationService.getOrInitialize()).thenReturn(Single.just(installation));
when(installationService.setAdditionalInformation(anyMap())).thenReturn(Single.error(new TechnicalException()));
TestObserver<InstallationReply> obs = cut.handle(command).test();
obs.awaitTerminalEvent();
obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.ERROR));
}
use of io.gravitee.am.repository.exceptions.TechnicalException in project gravitee-access-management by gravitee-io.
the class UserCommandHandlerTest method handleWithException.
@Test
public void handleWithException() {
UserPayload userPayload = new UserPayload();
UserCommand command = new UserCommand(userPayload);
userPayload.setId("user#1");
userPayload.setOrganizationId("orga#1");
when(userService.createOrUpdate(eq(ReferenceType.ORGANIZATION), eq("orga#1"), any(NewUser.class))).thenReturn(Single.error(new TechnicalException()));
TestObserver<UserReply> obs = cut.handle(command).test();
obs.awaitTerminalEvent();
obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.ERROR));
}
use of io.gravitee.am.repository.exceptions.TechnicalException in project gravitee-access-management by gravitee-io.
the class CallFactorProvider method sendChallenge.
@Override
public Completable sendChallenge(FactorContext context) {
final EnrolledFactor enrolledFactor = context.getData(FactorContext.KEY_ENROLLED_FACTOR, EnrolledFactor.class);
ResourceManager component = context.getComponent(ResourceManager.class);
ResourceProvider provider = component.getResourceProvider(configuration.getGraviteeResource());
if (provider instanceof MFAResourceProvider) {
MFAResourceProvider mfaProvider = (MFAResourceProvider) provider;
MFALink link = new MFALink(MFAType.CALL, enrolledFactor.getChannel().getTarget());
return mfaProvider.send(link);
} else {
return Completable.error(new TechnicalException("Resource referenced can't be used for MultiFactor Authentication with type SMS"));
}
}
use of io.gravitee.am.repository.exceptions.TechnicalException in project gravitee-access-management by gravitee-io.
the class CallFactorProvider method verify.
@Override
public Completable verify(FactorContext context) {
final String code = context.getData(FactorContext.KEY_CODE, String.class);
final EnrolledFactor enrolledFactor = context.getData(FactorContext.KEY_ENROLLED_FACTOR, EnrolledFactor.class);
ResourceManager component = context.getComponent(ResourceManager.class);
ResourceProvider provider = component.getResourceProvider(configuration.getGraviteeResource());
if (provider instanceof MFAResourceProvider) {
var mfaProvider = (MFAResourceProvider) provider;
var challenge = new MFAChallenge(enrolledFactor.getChannel().getTarget(), code);
return mfaProvider.verify(challenge);
} else {
return Completable.error(new TechnicalException("Resource referenced can't be used for MultiFactor Authentication with type Call"));
}
}
Aggregations