use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class RpErrorResponseFromHubIntegrationTest method shouldReturnErrorStatusCodeWhenCallToSamlEngineGoesAwry.
@Test
public void shouldReturnErrorStatusCodeWhenCallToSamlEngineGoesAwry() throws Exception {
final SessionId sessionId = aSessionIsCreated();
samlEngineStub.setUpStubForErrorResponseGenerateErrorOccurring();
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RP_ERROR_RESPONSE_RESOURCE).build(sessionId.getSessionId());
Response response = get(uri);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = response.readEntity(ErrorStatusDto.class);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_INPUT);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class AuthnRequestFromTransactionResourceIntegrationTest method idpSelected_shouldThrowIfIdpIsNotAvailable.
@Test
public void idpSelected_shouldThrowIfIdpIsNotAvailable() throws JsonProcessingException {
sessionId = aSessionIsCreated();
IdpSelected idpSelected = new IdpSelected("does-not-exist", principalIpAddress, REGISTERING, LEVEL_2, "this-is-an-analytics-session-id", "this-is-a-journey-type", abTestVariant);
Response response = postIdpSelected(idpSelected);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto error = response.readEntity(ErrorStatusDto.class);
assertThat(error.getExceptionType()).isEqualTo(ExceptionType.STATE_PROCESSING_VALIDATION);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldReturnForbiddenWhenIdpIsNotAvailable.
@Test
public void responsePost_shouldReturnForbiddenWhenIdpIsNotAvailable() throws JsonProcessingException {
samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.successResponse("idpDoesNotExist", LevelOfAssurance.LEVEL_2));
Response response = postIdpResponse(sessionId, samlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.FORBIDDEN.getStatusCode());
ErrorStatusDto responseEntity = response.readEntity(ErrorStatusDto.class);
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.IDP_DISABLED);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlProxySamlTransformationErrorExceptionMapperTest method shouldCreateAuditedErrorResponseForDuplicateRequestIdError.
@Test
public void shouldCreateAuditedErrorResponseForDuplicateRequestIdError() throws Exception {
Response response = exceptionMapper.handleException(new SamlDuplicateRequestIdException("error", new RuntimeException(), Level.DEBUG));
ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
assertThat(responseEntity.isAudited()).isTrue();
assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleSamlDuplicateRequestIdExceptionCorrectly.
@Test
public void shouldHandleSamlDuplicateRequestIdExceptionCorrectly() throws Exception {
SamlTransformationErrorException exception = new SamlDuplicateRequestIdException("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_DUPLICATE_REQUEST_ID);
checkLogLevel(exception.getLogLevel());
}
Aggregations