use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionCreationFailureExceptionMapper method handleException.
@Override
public Response handleException(SessionCreationFailureException exception) {
UUID errorId = UUID.randomUUID();
levelLogger.log(exception.getLogLevel(), exception);
eventLogger.logErrorEvent(errorId, getSessionId().orElse(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
final ErrorStatusDto entity = ErrorStatusDto.createAuditedErrorStatus(errorId, exception.getExceptionType(), exception.getMessage());
return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE).entity(entity).build();
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionNotFoundExceptionMapper method handleException.
@Override
public Response handleException(SessionNotFoundException exception) {
UUID errorId = UUID.randomUUID();
LOG.info(MessageFormat.format("{0} - Exception while processing request.", errorId), exception);
eventLogger.logErrorEvent(errorId, getSessionId().orElse(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
ErrorStatusDto entity = createUnauditedErrorStatus(errorId, SESSION_NOT_FOUND);
return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE).entity(entity).build();
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class IdaJsonProcessingExceptionMapperTest method toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient.
@Test
public void toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient() {
String clientErrorMessage = "This is a client error";
Response response = mapper.toResponse(new JsonMappingException(null, clientErrorMessage));
ErrorStatusDto errorStatus = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(errorStatus.isAudited()).isEqualTo(false);
assertThat(errorStatus.getClientMessage()).isEqualTo(clientErrorMessage);
assertThat(errorStatus.getExceptionType()).isEqualTo(ExceptionType.JSON_PARSING);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldReturnBadRequestWhenLevelOfAssuranceIsNotMet.
@Test
public void responsePost_shouldReturnBadRequestWhenLevelOfAssuranceIsNotMet() throws JsonProcessingException {
samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.successResponse(idpEntityId, LevelOfAssurance.LEVEL_3));
Response response = postIdpResponse(sessionId, samlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto responseEntity = response.readEntity(ErrorStatusDto.class);
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.STATE_PROCESSING_VALIDATION);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldReturnBadRequestWhenIdpIsDifferentThanSelectedIdp.
@Test
public void responsePost_shouldReturnBadRequestWhenIdpIsDifferentThanSelectedIdp() throws JsonProcessingException {
samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.successResponse("differentIdp", LevelOfAssurance.LEVEL_2));
Response response = postIdpResponse(sessionId, samlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto responseEntity = response.readEntity(ErrorStatusDto.class);
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.STATE_PROCESSING_VALIDATION);
}
Aggregations