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 SessionAlreadyExistingExceptionMapperTest method toResponse_shouldLogToAudit.
@Test
public void toResponse_shouldLogToAudit() {
SessionAlreadyExistingException exception = new SessionAlreadyExistingException(MESSAGE, SESSION_ID);
final Response response = mapper.toResponse(exception);
verify(hubEventLogger).logErrorEvent(any(UUID.class), eq(SESSION_ID), eq(MESSAGE));
final ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.isAudited()).isEqualTo(true);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.DUPLICATE_SESSION);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class StateProcessingValidationExceptionMapperTest method toResponse_shouldReturnUnauditedErrorStatus.
@Test
public void toResponse_shouldReturnUnauditedErrorStatus() {
when(servletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn(SESSION_ID);
String errorMessage = "error message";
StateProcessingValidationException exception = new StateProcessingValidationException(errorMessage, Level.ERROR);
final Response response = mapper.toResponse(exception);
verify(eventLogger).logErrorEvent(any(UUID.class), eq(aSessionId().with(SESSION_ID).build()), eq(errorMessage));
assertThat(response.getEntity()).isNotNull();
ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.isAudited()).isEqualTo(false);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.STATE_PROCESSING_VALIDATION);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class IdpDisabledExceptionMapperTest method toResponse_shouldReturnErrorResponseWithAuditingTrue.
@Test
public void toResponse_shouldReturnErrorResponseWithAuditingTrue() {
IdpDisabledException exception = new IdpDisabledException(ENTITY_ID);
Response response = exceptionMapper.toResponse(exception);
final ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.isAudited()).isEqualTo(true);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.IDP_DISABLED);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionCreationFailureExceptionMapperTest method toResponse_shouldLogToAudit.
@Test
public void toResponse_shouldLogToAudit() {
SessionCreationFailureException exception = new SessionCreationFailureException(MESSAGE, Level.ERROR, ExceptionType.DUPLICATE_SESSION);
final Response response = mapper.toResponse(exception);
verify(hubEventLogger).logErrorEvent(any(UUID.class), eq(SESSION_ID), eq(MESSAGE));
final ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.isAudited()).isEqualTo(true);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.DUPLICATE_SESSION);
}
Aggregations