use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class SessionNotFoundExceptionMapperTest method toResponse_shouldReturnUnauditedErrorStatus.
@Test
public void toResponse_shouldReturnUnauditedErrorStatus() {
SessionNotFoundException exception = new SessionNotFoundException(aSessionId().with(SESSION_ID).build());
Response response = mapper.toResponse(exception);
verify(eventLogger).logErrorEvent(any(UUID.class), eq(aSessionId().with(SESSION_ID).build()), eq("Session: 42 not found."));
assertThat(response.getEntity()).isNotNull();
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
assertThat(errorStatusDto.isAudited()).isEqualTo(false);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.SESSION_NOT_FOUND);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class RpAuthnRequestTranslatorResourceTest method shouldThrowExceptionWhenTheRequestIdIsADuplicate.
@Test
public void shouldThrowExceptionWhenTheRequestIdIsADuplicate() {
SamlRequestWithAuthnRequestInformationDto requestDto = aSamlAuthnRequest().withId("_iamtheoneandonlytheresnootherrequestididratherbe").withIssuer(TEST_RP).withPublicCert(TEST_RP_PUBLIC_SIGNING_CERT).withPrivateKey(TEST_RP_PRIVATE_SIGNING_KEY).build();
post(requestDto, Urls.SamlEngineUrls.TRANSLATE_RP_AUTHN_REQUEST_RESOURCE);
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_DUPLICATE_REQUEST_ID);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class RpAuthnRequestTranslatorResourceTest method authenticationRequestPost_shouldThrowExceptionWhenIssueInstantTooOld.
@Test
public void authenticationRequestPost_shouldThrowExceptionWhenIssueInstantTooOld() {
DateTimeFreezer.freezeTime();
DateTime issueInstant = DateTime.now().minusMinutes(5).minusSeconds(1);
SamlRequestWithAuthnRequestInformationDto requestDto = aSamlAuthnRequest().withIssueInstant(issueInstant).withIssuer(TEST_RP).withPublicCert(TEST_RP_PUBLIC_SIGNING_CERT).withPrivateKey(TEST_RP_PRIVATE_SIGNING_KEY).build();
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_REQUEST_TOO_OLD);
}
use of uk.gov.ida.common.ErrorStatusDto in project verify-hub by alphagov.
the class RpErrorResponseGeneratorResourceTest method shouldReturnAnErrorResponseGivenBadInput.
@Test
public void shouldReturnAnErrorResponseGivenBadInput() throws JsonProcessingException {
RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto = aRequestForErrorResponseFromHubDto().withStatus(null).build();
configStub.signResponsesAndUseSamlStandard(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId());
Response rpAuthnResponse = post(requestForErrorResponseFromHubDto, Urls.SamlEngineUrls.GENERATE_RP_ERROR_RESPONSE_RESOURCE);
assertThat(rpAuthnResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = rpAuthnResponse.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 MatchingServiceResponseTranslatorResourceTest method shouldNotReturnADtoWhenResponseIs_Nonsense.
@Test
public void shouldNotReturnADtoWhenResponseIs_Nonsense() {
final SamlResponseContainerDto samlResponseContainerDto = new SamlResponseContainerDto(StringUtils.rightPad("test", 2000, "x"), TEST_RP);
Response clientResponse = postToSamlEngine(samlResponseContainerDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
ErrorStatusDto errorStatusDto = clientResponse.readEntity(ErrorStatusDto.class);
assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML);
}
Aggregations