use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxyDuplicateRequestExceptionMapperTest method shouldCreateAuditedErrorResponseForDuplicateRequestIdError.
@Test
public void shouldCreateAuditedErrorResponseForDuplicateRequestIdError() {
SamlDuplicateRequestIdException exception = new SamlDuplicateRequestIdException("error", new RuntimeException(), Level.DEBUG);
SessionId sessionId = SessionId.createNewSessionId();
when(httpServletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn(sessionId.getSessionId());
Response response = exceptionMapper.handleException(exception);
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(responseEntity.isAudited()).isTrue();
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID);
verify(eventSinkMessageSender).audit(eq(exception), any(UUID.class), eq(sessionId));
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxySamlTransformationErrorExceptionMapperTest method shouldCreateAuditedErrorResponseForRequestTooOldError.
@Test
public void shouldCreateAuditedErrorResponseForRequestTooOldError() {
Response response = exceptionMapper.handleException(new SamlRequestTooOldException("error", new RuntimeException(), Level.DEBUG));
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(responseEntity.isAudited()).isTrue();
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_REQUEST_TOO_OLD);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxySamlTransformationErrorExceptionMapper method handleException.
@Override
protected Response handleException(SamlTransformationErrorException exception) {
UUID errorId = UUID.randomUUID();
eventSinkMessageSender.audit(exception, errorId, getSessionId().orElse(SessionId.NO_SESSION_CONTEXT_IN_ERROR));
levelLogger.log(exception.getLogLevel(), exception, errorId);
ErrorStatusDto auditedErrorStatus = ErrorStatusDto.createAuditedErrorStatus(errorId, getExceptionTypeForSamlException(exception));
return Response.status(Response.Status.BAD_REQUEST).entity(auditedErrorStatus).build();
}
Aggregations