use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleSamlTransformationErrorExceptionCorrectly.
@Test
public void shouldHandleSamlTransformationErrorExceptionCorrectly() throws Exception {
SamlTransformationErrorException exception = new SamlTransformationErrorException("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);
checkLogLevel(exception.getLogLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldPassthroughErrorIdAndExceptionType.
@Test
public void shouldPassthroughErrorIdAndExceptionType() throws Exception {
UUID errorId = UUID.randomUUID();
final ExceptionType exceptionType = ExceptionType.IDA_SOAP;
ApplicationException applicationException = createUnauditedException(exceptionType, errorId);
final Response response = samlEngineExceptionMapper.toResponse(applicationException);
assertThat(response.hasEntity()).isTrue();
ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.getErrorId()).isEqualTo(errorId);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(exceptionType);
checkLogLevel(applicationException.getExceptionType().getLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleUnableToGenerateSamlExceptionCorrectly.
@Test
public void shouldHandleUnableToGenerateSamlExceptionCorrectly() throws Exception {
final UnableToGenerateSamlException exception = new UnableToGenerateSamlException("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();
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_INPUT);
checkLogLevel(exception.getLogLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleSamlRequestTooOldExceptionCorrectly.
@Test
public void shouldHandleSamlRequestTooOldExceptionCorrectly() throws Exception {
SamlTransformationErrorException exception = new SamlRequestTooOldException("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_REQUEST_TOO_OLD);
checkLogLevel(exception.getLogLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldReturnBadRequestForNoKeyConfiguredForEntityException.
@Test
public void shouldReturnBadRequestForNoKeyConfiguredForEntityException() {
Response response = samlEngineExceptionMapper.toResponse(new NoKeyConfiguredForEntityException("error"));
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
final ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.NO_KEY_CONFIGURED_FOR_ENTITY);
checkLogLevel(Level.ERROR);
}
Aggregations