use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class IdaJsonProcessingExceptionMapperTest method toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient.
@Test
public void toResponse_shouldReturnBadRequestAndErrorStatusDtoWhenErrorDeemedToBeFromClient() {
String clientErrorMessage = "This is a client error";
Response response = mapper.toResponse(new JsonMappingException(null, clientErrorMessage));
ErrorStatusDto errorStatus = (ErrorStatusDto) response.getEntity();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(errorStatus.isAudited()).isEqualTo(false);
assertThat(errorStatus.getClientMessage()).isEqualTo(clientErrorMessage);
assertThat(errorStatus.getExceptionType()).isEqualTo(ExceptionType.JSON_PARSING);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorResourceWithRedisTest method handleResponseFromIdp_shouldThrowExceptionIfmdsAssertionIsReplayedInResponseFromIdp.
@Test
public void handleResponseFromIdp_shouldThrowExceptionIfmdsAssertionIsReplayedInResponseFromIdp() throws Exception {
String authnStatementAssertionId = "authnStatementAssertionId" + UUID.randomUUID().toString();
String mdsStatementAssertionId = "mdsStatementAssertionId" + UUID.randomUUID().toString();
SamlAuthnResponseTranslatorDto samlResponseDto_1 = getSuccessSamlAuthnResponseTranslatorDto(STUB_IDP_ONE, authnStatementAssertionId + "-1", mdsStatementAssertionId);
SamlAuthnResponseTranslatorDto samlResponseDto_2 = getSuccessSamlAuthnResponseTranslatorDto(STUB_IDP_ONE, authnStatementAssertionId + "-2", mdsStatementAssertionId);
Response clientResponse = postToSamlEngine(samlResponseDto_1);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
clientResponse = postToSamlEngine(samlResponseDto_2);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = clientResponse.readEntity(ErrorStatusDto.class);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class MatchingServiceHealthcheckResponseTranslatorResourceTest method should_shouldReturnErrorStatusDtoWhenThereIsAProblem.
@Test
public void should_shouldReturnErrorStatusDtoWhenThereIsAProblem() {
Response response = postResponseForTranslation(new SamlMessageDto(Base64.getEncoder().encodeToString("<saml/>".getBytes())));
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto entity = response.readEntity(ErrorStatusDto.class);
assertThat(entity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class RpAuthnRequestTranslatorResourceTest method shouldThrowInvalidSamlExceptionWhenTheAuthnRequestIsInvalid.
@Test
public void shouldThrowInvalidSamlExceptionWhenTheAuthnRequestIsInvalid() {
SamlRequestWithAuthnRequestInformationDto requestDto = aSamlAuthnRequest().withPublicCert(TEST_RP_PUBLIC_SIGNING_CERT).withPrivateKey(TEST_RP_PRIVATE_SIGNING_KEY).buildInvalid();
Response response = post(requestDto, Urls.SamlEngineUrls.TRANSLATE_RP_AUTHN_REQUEST_RESOURCE);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto entity = response.readEntity(ErrorStatusDto.class);
assertThat(entity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SamlEngineExceptionMapperTest method shouldHandleSamlContextExceptionWithFailedToDecryptCorrectly.
@Test
public void shouldHandleSamlContextExceptionWithFailedToDecryptCorrectly() throws Exception {
final SamlContextException exception = new SamlContextException(UUID.randomUUID().toString(), "entityId", new SamlFailedToDecryptException("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_FAILED_TO_DECRYPT);
checkLogLevel(exception.getLogLevel());
}
Aggregations