Search in sources :

Example 11 with InboundResponseFromMatchingServiceDto

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

the class MatchingServiceResponseServiceTest method handle_shouldNotifyPolicyWhenTransformationSucceedsForANoMatch.

@Test
public void handle_shouldNotifyPolicyWhenTransformationSucceedsForANoMatch() {
    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService, inResponseTo, "issuer", Optional.<String>absent(), Optional.<LevelOfAssurance>absent());
    when(samlEngineProxy.translateMatchingServiceResponse(samlResponseDto)).thenReturn(inboundResponseFromMatchingServiceDto);
    matchingServiceResponseService.handleSuccessResponse(sessionId, samlResponseDto);
    verify(waitingForMatchingServiceResponseStateController, times(1)).handleNoMatchResponseFromMatchingService(Matchers.<NoMatchFromMatchingService>any());
}
Also used : InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.Test)

Example 12 with InboundResponseFromMatchingServiceDto

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

the class EidasMatchingServiceResourceIntegrationTest method shouldTransitionToEidasAwaitingCycle3DataStateWhenNoMatchIsReceivedForEidasCycle0And1WithCycle3Enabled.

@Test
public void shouldTransitionToEidasAwaitingCycle3DataStateWhenNoMatchIsReceivedForEidasCycle0And1WithCycle3Enabled() 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.setUpStubForEnteringAwaitingCycle3DataState(RP_ENTITY_ID);
    final Response response = postAttributeQueryResponseToPolicy(sessionId);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    assertThat(getSessionStateName(sessionId)).isEqualTo(EidasAwaitingCycle3DataState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) EidasAwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.Test)

Example 13 with InboundResponseFromMatchingServiceDto

use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto 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());
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) Response(javax.ws.rs.core.Response) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) SuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState) Test(org.junit.Test)

Example 14 with InboundResponseFromMatchingServiceDto

use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto 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);
}
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)

Example 15 with InboundResponseFromMatchingServiceDto

use of uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto 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());
}
Also used : SamlResponseDto(uk.gov.ida.hub.policy.contracts.SamlResponseDto) Response(javax.ws.rs.core.Response) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto) Test(org.junit.Test)

Aggregations

InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)15 Test (org.junit.Test)10 URI (java.net.URI)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 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)2 ApplicationException (uk.gov.ida.exceptions.ApplicationException)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