use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method toResponse_shouldReturnAuditedErrorResponseWhenExceptionHasBeenAuditedAlready.
@Test
public void toResponse_shouldReturnAuditedErrorResponseWhenExceptionHasBeenAuditedAlready() throws Exception {
ApplicationException applicationException = createAuditedException(ExceptionType.INVALID_SAML, UUID.randomUUID());
final Response response = samlEngineExceptionMapper.toResponse(applicationException);
final ErrorStatusDto entity = (ErrorStatusDto) response.getEntity();
assertThat(entity.isAudited()).isTrue();
checkLogLevel(applicationException.getExceptionType().getLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldCreateUnauditedErrorResponse.
@Test
public void shouldCreateUnauditedErrorResponse() throws Exception {
final SamlTransformationErrorException exception = new SamlTransformationErrorException("error", new RuntimeException(), Level.DEBUG);
Response response = samlEngineExceptionMapper.toResponse(exception);
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(responseEntity.isAudited()).isFalse();
checkLogLevel(exception.getLogLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method toResponse_shouldReturnUnauditedErrorResponseWhenExceptionHasNotBeenAudited.
@Test
public void toResponse_shouldReturnUnauditedErrorResponseWhenExceptionHasNotBeenAudited() throws Exception {
ApplicationException applicationException = createUnauditedExceptionThatShouldNotBeAudited();
final Response response = samlEngineExceptionMapper.toResponse(applicationException);
final ErrorStatusDto entity = (ErrorStatusDto) response.getEntity();
assertThat(entity.isAudited()).isEqualTo(false);
checkLogLevel(applicationException.getExceptionType().getLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleSamlFailedToDecryptErrorExceptionCorrectly.
@Test
public void shouldHandleSamlFailedToDecryptErrorExceptionCorrectly() throws Exception {
SamlTransformationErrorException exception = new SamlFailedToDecryptException("error", new RuntimeException(), Level.DEBUG);
final Response response = samlEngineExceptionMapper.toResponse(exception);
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(responseEntity.isAudited()).isFalse();
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_FAILED_TO_DECRYPT);
checkLogLevel(exception.getLogLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleSamlContextExceptionCorrectly.
@Test
public void shouldHandleSamlContextExceptionCorrectly() throws Exception {
final SamlContextException exception = new SamlContextException(UUID.randomUUID().toString(), "entityId", new SamlTransformationErrorException("error", Level.ERROR));
Response response = samlEngineExceptionMapper.toResponse(exception);
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(responseEntity.isAudited()).isFalse();
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
checkLogLevel(exception.getLogLevel());
}
Aggregations