use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class AuthnRequestFromTransactionResourceIntegrationTest method idpSelected_shouldThrowIfSessionInWrongState.
@Test
public void idpSelected_shouldThrowIfSessionInWrongState() {
sessionId = SessionId.createNewSessionId();
TestSessionResourceHelper.createSessionInSuccessfulMatchState(sessionId, transactionEntityId, idpEntityId, client, buildUriForTestSession(SUCCESSFUL_MATCH_STATE, sessionId));
Response response = postIdpSelected(new IdpSelected("does-not-exist", principalIpAddress, REGISTERING, LEVEL_2, "this-is-an-analytics-session-id", "this-is-a-journey-type", abTestVariant));
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto error = response.readEntity(ErrorStatusDto.class);
assertThat(error.getExceptionType()).isEqualTo(ExceptionType.INVALID_STATE);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class ExceptionFactory method createDisabledEntityException.
private WebApplicationException createDisabledEntityException(ExceptionType exceptionType) {
final ErrorStatusDto entity = createUnauditedErrorStatus(UUID.randomUUID(), exceptionType);
final Response response = Response.status(Response.Status.FORBIDDEN).entity(entity).build();
return new WebApplicationException(response);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class ExceptionFactory method createInvalidAssertionConsumerServiceIndexException.
public WebApplicationException createInvalidAssertionConsumerServiceIndexException(String entityId, Integer assertionConsumerServiceIndex) {
LOG.error(format("Invalid assertion consumer service index ''{0}'' for ''{1}''.", assertionConsumerServiceIndex, entityId));
final ErrorStatusDto entity = createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.INVALID_ASSERTION_CONSUMER_INDEX);
final Response response = Response.status(Response.Status.NOT_FOUND).entity(entity).build();
return new WebApplicationException(response);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxyApplicationExceptionMapperTest method toResponse_shouldReturnAuditedErrorResponse.
@Test
public void toResponse_shouldReturnAuditedErrorResponse() {
ApplicationException exception = createAuditedException(exceptionType, errorId);
final Response response = mapper.toResponse(exception);
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
assertThat(responseEntity.isAudited()).isTrue();
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxyExceptionMapperTest method shouldCreateAuditedErrorResponse.
@Test
public void shouldCreateAuditedErrorResponse() {
Response response = exceptionMapper.handleException(new RuntimeException());
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
assertThat(responseEntity.isAudited()).isTrue();
}
Aggregations