use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method shouldReturnOkWhenASuccessMatchingServiceResponseIsReceived.
@Test
public void shouldReturnOkWhenASuccessMatchingServiceResponseIsReceived() throws Exception {
SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForRegistration(sessionId, idpEntityId);
anIdpAuthnRequestWasGenerated(sessionId);
anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.MatchingServiceMatch, translatedAuthnRequest.getId(), msaEntityId, Optional.of("assertionBlob"), Optional.of(LEVEL_2));
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
Response response = postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(getSessionStateName(sessionId)).isEqualTo(SuccessfulMatchState.class.getName());
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled.
private void aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled(SessionId sessionId) throws JsonProcessingException {
SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService, translatedAuthnRequest.getId(), msaEntityId, Optional.<String>absent(), Optional.<LevelOfAssurance>absent());
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
List<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of(UserAccountCreationAttribute.CURRENT_ADDRESS);
configStub.setUpStubForUserAccountCreation(rpEntityId, userAccountCreationAttributes);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest.
@Test
public void responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest() throws Exception {
SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForRegistration(sessionId, idpEntityId);
anIdpAuthnRequestWasGenerated(sessionId);
anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
aCycle3AttributeHasBeenSentToPolicyFromTheUser(sessionId, "#1");
SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.MatchingServiceMatch, "a-thoroughly-different-request-id", msaEntityId, Optional.of("assertionBlob"), Optional.of(LEVEL_2));
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
Response response = postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
// Note that the state does not get updated if there is a StateProcessingValidationException
assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle3MatchRequestSentState.class.getName());
}
Aggregations