use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method toResponse_shouldCreateResponseWithUnauditedErrorStatus.
@Test
public void toResponse_shouldCreateResponseWithUnauditedErrorStatus() throws Exception {
SamlTransformationErrorException exception = aSamlTransformationFailureException().build();
Response response = samlEngineExceptionMapper.toResponse(exception);
assertThat(response.getEntity()).isNotNull();
final ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.isAudited()).isEqualTo(false);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
checkLogLevel(exception.getLogLevel());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method assertError.
private void assertError(Response.StatusType statusType, final Response response, final ExceptionType exceptionType) {
assertThat(response.getStatus()).isEqualTo(statusType.getStatusCode());
ErrorStatusDto entity = response.readEntity(ErrorStatusDto.class);
assertThat(entity.getErrorId()).isNotNull();
assertThat(entity.getExceptionType()).isEqualTo(exceptionType);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxySamlTransformationErrorExceptionMapperTest method shouldCreateAuditedErrorResponseForInvalidSaml.
@Test
public void shouldCreateAuditedErrorResponseForInvalidSaml() {
Response response = exceptionMapper.handleException(new TestSamlTransformationErrorException("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);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldHandleErrorResponseFromSamlEngine.
@Test
public void responsePost_shouldHandleErrorResponseFromSamlEngine() throws Exception {
samlEngineStub.setupStubForIdpAuthnResponseTranslateReturningError(ErrorStatusDto.createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.INVALID_SAML));
Response response = postIdpResponse(sessionId, samlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto responseEntity = response.readEntity(ErrorStatusDto.class);
assertThat(responseEntity.getExceptionType()).isEqualTo(ErrorStatusDto.createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.INVALID_SAML).getExceptionType());
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldReturnBadRequestSessionDoesNotExist.
@Test
public void responsePost_shouldReturnBadRequestSessionDoesNotExist() {
Response response = postIdpResponse(SessionId.createNewSessionId(), samlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto responseEntity = response.readEntity(ErrorStatusDto.class);
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.SESSION_NOT_FOUND);
}
Aggregations