Search in sources :

Example 1 with InboundResponseFromMatchingServiceDto

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

the class EidasMatchingServiceResourceIntegrationTest method shouldTransitionToNoMatchStateWhenNoMatchIsReceivedForEidasCycle0And1WithCycle3Disabled.

@Test
public void shouldTransitionToNoMatchStateWhenNoMatchIsReceivedForEidasCycle0And1WithCycle3Disabled() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    selectACountry(sessionId, NETHERLANDS);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    postAuthnResponseToPolicy(sessionId);
    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService, translatedAuthnRequest.getId(), MSA_ENTITY_ID, Optional.absent(), Optional.absent());
    samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
    configStub.setUpStubForCycle01NoMatchCycle3Disabled(RP_ENTITY_ID);
    final Response response = postAttributeQueryResponseToPolicy(sessionId);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    assertThat(getSessionStateName(sessionId)).isEqualTo(NoMatchState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) SessionId(uk.gov.ida.hub.policy.domain.SessionId) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.Test)

Example 2 with InboundResponseFromMatchingServiceDto

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

the class EidasMatchingServiceResourceIntegrationTest method shouldTransitionToEidasSuccessfulMatchStateWhenMatchIsReceivedForEidasCycle0And1.

@Test
public void shouldTransitionToEidasSuccessfulMatchStateWhenMatchIsReceivedForEidasCycle0And1() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    selectACountry(sessionId, NETHERLANDS);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    postAuthnResponseToPolicy(sessionId);
    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.MatchingServiceMatch, translatedAuthnRequest.getId(), MSA_ENTITY_ID, Optional.of("assertionBlob"), Optional.of(LevelOfAssurance.LEVEL_2));
    samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
    final Response response = postAttributeQueryResponseToPolicy(sessionId);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    assertThat(getSessionStateName(sessionId)).isEqualTo(EidasSuccessfulMatchState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) EidasSuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.EidasSuccessfulMatchState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.Test)

Example 3 with InboundResponseFromMatchingServiceDto

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

the class MatchingServiceResponseService method handleSuccessResponse.

public void handleSuccessResponse(SessionId sessionId, SamlResponseDto samlResponse) {
    getSessionIfItExists(sessionId);
    SamlResponseContainerDto samlResponseContainer = new SamlResponseContainerDto(samlResponse.getSamlResponse(), sessionRepository.getRequestIssuerEntityId(sessionId));
    try {
        InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = samlEngineProxy.translateMatchingServiceResponse(samlResponseContainer);
        updateSessionState(sessionId, inboundResponseFromMatchingServiceDto);
    } catch (ApplicationException e) {
        // this is not ideal but if the call to saml-proxy fails we want to log the failure
        // in the state and then process the exception
        logExceptionAndUpdateState("Error translating matching service response", sessionId, e);
    }
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) SamlResponseContainerDto(uk.gov.ida.hub.policy.contracts.SamlResponseContainerDto) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)

Example 4 with InboundResponseFromMatchingServiceDto

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

the class MatchingServiceResponseServiceTest method handle_shouldLogToEventSinkAndNotifyPolicyOnRequesterError.

@Test
public void handle_shouldLogToEventSinkAndNotifyPolicyOnRequesterError() {
    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.RequesterError, inResponseTo, "issuer", Optional.empty(), Optional.empty());
    when(samlEngineProxy.translateMatchingServiceResponse(any())).thenReturn(inboundResponseFromMatchingServiceDto);
    matchingServiceResponseService.handleSuccessResponse(sessionId, samlResponseDto);
    verify(waitingForMatchingServiceResponseStateController, times(1)).handleRequestFailure();
    verify(eventLogger).logErrorEvent(format("Requester error in response from matching service for session {0}", sessionId), sessionId);
}
Also used : InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.jupiter.api.Test)

Example 5 with InboundResponseFromMatchingServiceDto

use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto 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.empty(), Optional.empty());
    samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
    configStub.setUpStubForCycle01NoMatchCycle3Disabled(rpEntityId);
    List<UserAccountCreationAttribute> userAccountCreationAttributes = List.of(UserAccountCreationAttribute.CURRENT_ADDRESS);
    configStub.setUpStubForUserAccountCreation(rpEntityId, userAccountCreationAttributes);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
    postResponse(uri, 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

InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)15 URI (java.net.URI)7 Test (org.junit.jupiter.api.Test)7 SamlResponseDto (uk.gov.ida.hub.policy.contracts.SamlResponseDto)7 Response (javax.ws.rs.core.Response)6 SessionId (uk.gov.ida.hub.policy.domain.SessionId)6 Test (org.junit.Test)3 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)2 ApplicationException (uk.gov.ida.exceptions.ApplicationException)1 SamlResponseContainerDto (uk.gov.ida.hub.policy.contracts.SamlResponseContainerDto)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)1 EidasAwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState)1 EidasSuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.EidasSuccessfulMatchState)1 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)1 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)1