use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorServiceTest method translateAndCheckCommonFields.
private InboundResponseFromIdpDto translateAndCheckCommonFields() {
InboundResponseFromIdpDto result = service.translate(responseContainer);
checkAlwaysPresentFields(result);
return result;
}
use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorResourceTest method shouldTranslateAFraudResponseFromIdp.
@Test
public void shouldTranslateAFraudResponseFromIdp() throws Exception {
String persistentId = UUID.randomUUID().toString();
final org.opensaml.saml.saml2.core.Response samlAuthnResponse = authnResponseFactory.aFraudResponseFromIdpBuilder(STUB_IDP_ONE, persistentId).withDestination(IDP_RESPONSE_ENDPOINT).build();
String saml = authnResponseFactory.transformResponseToSaml(samlAuthnResponse);
SamlAuthnResponseTranslatorDto samlResponseDto = aSamlAuthnResponseTranslatorDto().withSamlResponse(saml).withMatchingServiceEntityId(TEST_RP_MS).build();
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromIdpDto inboundResponseFromIdpDto = clientResponse.readEntity(InboundResponseFromIdpDto.class);
assertThat(inboundResponseFromIdpDto.getStatus()).isEqualTo(IdpIdaStatus.Status.Success);
assertThat(inboundResponseFromIdpDto.getIssuer()).isEqualTo(samlAuthnResponse.getIssuer().getValue());
// TODO consider checking the values of the ones we've checked presence of below
assertThat(inboundResponseFromIdpDto.getAuthnStatementAssertionBlob().isPresent()).isTrue();
assertThat(inboundResponseFromIdpDto.getEncryptedMatchingDatasetAssertion().isPresent()).isTrue();
assertThat(inboundResponseFromIdpDto.getPersistentId().get()).isEqualTo(persistentId);
assertThat(inboundResponseFromIdpDto.getLevelOfAssurance().get()).isEqualTo(LevelOfAssurance.LEVEL_X);
assertThat(inboundResponseFromIdpDto.getPrincipalIpAddressAsSeenByIdp().isPresent()).isTrue();
assertThat(inboundResponseFromIdpDto.getFraudIndicator().isPresent()).isTrue();
assertThat(inboundResponseFromIdpDto.getIdpFraudEventId().isPresent()).isTrue();
}
use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorResourceTest method shouldTranslateARequesterErrorResponseFromIdp.
@Test
public void shouldTranslateARequesterErrorResponseFromIdp() throws Exception {
final org.opensaml.saml.saml2.core.Response samlAuthnResponse = authnResponseFactory.anAuthnFailedResponseFromIdpBuilder(STUB_IDP_ONE).withDestination(IDP_RESPONSE_ENDPOINT).withStatus(REQUESTER_ERROR_STATUS).build();
String saml = authnResponseFactory.transformResponseToSaml(samlAuthnResponse);
SamlAuthnResponseTranslatorDto samlResponseDto = aSamlAuthnResponseTranslatorDto().withSamlResponse(saml).withMatchingServiceEntityId("IGNOREME").build();
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromIdpDto inboundResponseFromIdpDto = clientResponse.readEntity(InboundResponseFromIdpDto.class);
assertThat(inboundResponseFromIdpDto.getStatus()).isEqualTo(IdpIdaStatus.Status.RequesterError);
assertThat(inboundResponseFromIdpDto.getIssuer()).isEqualTo(samlAuthnResponse.getIssuer().getValue());
checkFieldsForUnsuccessfulResponseDTO(inboundResponseFromIdpDto);
}
use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorResourceTest method shouldTranslateAnAuthenticationFailedResponseFromIdp.
@Test
public void shouldTranslateAnAuthenticationFailedResponseFromIdp() throws Exception {
final org.opensaml.saml.saml2.core.Response samlAuthnResponse = authnResponseFactory.anAuthnFailedResponseFromIdpBuilder(STUB_IDP_ONE).withDestination(IDP_RESPONSE_ENDPOINT).withStatus(AUTHN_FAILED_STATUS).build();
String saml = authnResponseFactory.transformResponseToSaml(samlAuthnResponse);
SamlAuthnResponseTranslatorDto samlResponseDto = aSamlAuthnResponseTranslatorDto().withSamlResponse(saml).withMatchingServiceEntityId("IGNOREME").build();
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromIdpDto inboundResponseFromIdpDto = clientResponse.readEntity(InboundResponseFromIdpDto.class);
assertThat(inboundResponseFromIdpDto.getStatus()).isEqualTo(IdpIdaStatus.Status.AuthenticationFailed);
assertThat(inboundResponseFromIdpDto.getIssuer()).isEqualTo(samlAuthnResponse.getIssuer().getValue());
checkFieldsForUnsuccessfulResponseDTO(inboundResponseFromIdpDto);
}
use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorResourceTest method shouldPreserveStatusMessageForRequesterError.
@Test
public void shouldPreserveStatusMessageForRequesterError() throws Exception {
final String statusMessage = "status-message";
final org.opensaml.saml.saml2.core.Response samlAuthnResponse = authnResponseFactory.anAuthnFailedResponseFromIdpBuilder(STUB_IDP_ONE).withDestination(IDP_RESPONSE_ENDPOINT).withStatus(StatusBuilder.aStatus().withMessage(StatusMessageBuilder.aStatusMessage().withMessage(statusMessage).build()).withStatusCode(StatusCodeBuilder.aStatusCode().withValue(StatusCode.REQUESTER).build()).build()).build();
String saml = authnResponseFactory.transformResponseToSaml(samlAuthnResponse);
SamlAuthnResponseTranslatorDto samlResponseDto = aSamlAuthnResponseTranslatorDto().withSamlResponse(saml).withMatchingServiceEntityId(TEST_RP_MS).build();
Response clientResponse = postToSamlEngine(samlResponseDto);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromIdpDto inboundResponseFromIdpDto = clientResponse.readEntity(InboundResponseFromIdpDto.class);
assertThat(inboundResponseFromIdpDto.getStatus()).isEqualTo(IdpIdaStatus.Status.RequesterError);
assertThat(inboundResponseFromIdpDto.getStatusMessage().get()).isEqualTo(statusMessage);
}
Aggregations