Search in sources :

Example 16 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class EidasCycle3DataResourceTest method shouldGetCycle3AttributeRequestDataFromConfiguration.

@Test
public void shouldGetCycle3AttributeRequestDataFromConfiguration() throws JsonProcessingException {
    final SessionId sessionId = SessionIdBuilder.aSessionId().build();
    final String rpEntityId = new EidasCycle3DTO(sessionId).getRequestIssuerEntityId();
    final Response sessionCreatedResponse = createSessionInEidasAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    final Cycle3AttributeRequestData actualResponse = getCycle3Data(sessionId);
    final Cycle3AttributeRequestData expectedResponse = aCycle3AttributeRequestData().withAttributeName(cycle3Attribute.getAttributeName().get()).withRequestIssuerId(rpEntityId).build();
    assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
Also used : Response(javax.ws.rs.core.Response) MatchingProcessDto(uk.gov.ida.hub.policy.domain.MatchingProcessDto) EidasCycle3DTO(uk.gov.ida.integrationtest.hub.policy.rest.EidasCycle3DTO) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) Cycle3AttributeRequestDataBuilder.aCycle3AttributeRequestData(uk.gov.ida.hub.policy.builder.domain.Cycle3AttributeRequestDataBuilder.aCycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 17 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId 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 18 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId 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 19 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class EidasSessionResourceIntegrationTest method selectACountry.

private SessionId selectACountry(EidasCountryDto dto) {
    SessionId sessionId = createSessionInCountrySelectingState();
    TestSessionResourceHelper.selectCountryInSession(sessionId, client, policy.uri(UriBuilder.fromPath(Urls.PolicyUrls.COUNTRIES_RESOURCE).path(Urls.PolicyUrls.COUNTRY_SET_PATH).build(sessionId, dto.getSimpleId()).toString()));
    return sessionId;
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId)

Example 20 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class EidasSessionResourceIntegrationTest method shouldReturnOkWhenSuccessAuthnResponseIsReceived.

@Test
public void shouldReturnOkWhenSuccessAuthnResponseIsReceived() throws Exception {
    SessionId sessionId = selectACountry(NETHERLANDS);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    Response response = postAuthnResponseToPolicy(sessionId);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseAction expectedResult = ResponseAction.success(sessionId, false, LevelOfAssurance.LEVEL_2);
    assertThat(response.readEntity(ResponseAction.class)).isEqualToComparingFieldByField(expectedResult);
    assertThatCurrentStateForSesssionIs(sessionId, EidasCycle0And1MatchRequestSentState.class);
}
Also used : Response(javax.ws.rs.core.Response) SessionId(uk.gov.ida.hub.policy.domain.SessionId) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Aggregations

SessionId (uk.gov.ida.hub.policy.domain.SessionId)92 Test (org.junit.Test)83 Response (javax.ws.rs.core.Response)41 URI (java.net.URI)33 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)14 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)13 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)12 Matchers.anyString (org.mockito.Matchers.anyString)9 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)9 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)6 MatchingServiceRequestErrorState (uk.gov.ida.hub.policy.domain.state.MatchingServiceRequestErrorState)6 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)5 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto)5 Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)5 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)5 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)5 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)5 SamlRequestDto (uk.gov.ida.hub.policy.contracts.SamlRequestDto)4 SamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto)4 AuthnRequestFromHubContainerDto (uk.gov.ida.hub.policy.domain.AuthnRequestFromHubContainerDto)4