Search in sources :

Example 1 with SamlResponseDto

use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.

the class MatchingServiceResourcesIntegrationTest method samlEngineRespondsToATranslateAttributeQueryWithAnErrorStatusDto.

private void samlEngineRespondsToATranslateAttributeQueryWithAnErrorStatusDto(SessionId sessionId) throws JsonProcessingException {
    final SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
    samlEngineStub.setupStubForAttributeResponseTranslateReturningError(ErrorStatusDto.createUnauditedErrorStatus(UUID.randomUUID(), ExceptionType.INVALID_SAML));
    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());
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) Response(javax.ws.rs.core.Response) URI(java.net.URI)

Example 2 with SamlResponseDto

use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.

the class MatchingServiceResourcesIntegrationTest method responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle1MatchRequest.

@Test
public void responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle1MatchRequest() 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, "a-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(Cycle0And1MatchRequestSentState.class.getName());
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) Response(javax.ws.rs.core.Response) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.Test)

Example 3 with SamlResponseDto

use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.

the class MatchingServiceResourcesIntegrationTest method aUserAccountCreationResponseIsReceived.

private void aUserAccountCreationResponseIsReceived(SessionId sessionId, MatchingServiceIdaStatus status) throws JsonProcessingException {
    SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
    InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(status, 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);
    postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)

Example 4 with SamlResponseDto

use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.

the class MatchingServiceResourcesIntegrationTest method aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled.

private String aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(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);
    final String cycle3Attribute = configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
    postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
    return cycle3Attribute;
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)

Example 5 with SamlResponseDto

use of uk.gov.ida.hub.policy.contracts.SamlResponseDto in project verify-hub by alphagov.

the class MatchingServiceResourcesIntegrationTest method aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Disabled.

private void aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Disabled(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);
    configStub.setUpStubForCycle01NoMatchCycle3Disabled(rpEntityId);
    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);
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)

Aggregations

URI (java.net.URI)8 SamlResponseDto (uk.gov.ida.hub.policy.contracts.SamlResponseDto)8 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)7 Response (javax.ws.rs.core.Response)4 Test (org.junit.Test)3 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)2 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)1 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)1