Search in sources :

Example 56 with SessionId

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

the class SessionServiceTest method shouldCreateASessionFromInputs.

@Test
public void shouldCreateASessionFromInputs() {
    // Given
    SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
    URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
    final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
    givenSamlEngineTranslatesRequest(samlResponse);
    givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
    givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, false);
    // When
    SessionId result = service.create(requestDto);
    // Then
    assertThat(result, is(sessionId));
}
Also used : SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto) SamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto) URI(java.net.URI) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) Test(org.junit.Test)

Example 57 with SessionId

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

the class EidasSessionResourceContractTest method shouldGetValidatedEidasAuthnResponseFromSamlEngineVerification.

@PactVerification(value = SAML_ENGINE_SERVICE, fragment = "shouldGetValidatedEidasAuthnResponseFromSamlEngine")
@Test
public void shouldGetValidatedEidasAuthnResponseFromSamlEngineVerification() throws Exception {
    configStub.setupStubForEidasRPCountries(TEST_RP, EIDAS_COUNTRIES.stream().map(EidasCountryDto::getEntityId).collect(Collectors.toList()));
    SessionId sessionId = createSessionInCountrySelectingState();
    selectACountry(sessionId);
    Response response = postAuthnResponseToPolicy(sessionId);
    assertThatResponseIsSuccess(response);
    assertThatAQRReceivedBySamlSoapProxyHasSameDataAsSamlEngineSent();
}
Also used : Response(javax.ws.rs.core.Response) EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Example 58 with SessionId

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

the class AuthnRequestFromTransactionResourceIntegrationTest method getRequestIssuerId_shouldReturnRequestIssuerId.

@Test
public void getRequestIssuerId_shouldReturnRequestIssuerId() {
    SessionId session = SessionId.createNewSessionId();
    TestSessionResourceHelper.createSessionInIdpSelectedState(session, samlResponse.getIssuer(), idpEntityId, client, buildUriForTestSession(IDP_SELECTED_STATE, session));
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_FROM_TRANSACTION_ROOT + Urls.PolicyUrls.AUTHN_REQUEST_ISSUER_ID_PATH).build(session);
    Response response = client.target(policy.uri(uri.toASCIIString())).request().get();
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    assertThat(response.readEntity(String.class)).isEqualTo(samlResponse.getIssuer());
}
Also used : Response(javax.ws.rs.core.Response) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Example 59 with SessionId

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

the class Cycle3DataResourceTest method shouldGetCycle3AttributeRequestDataFromConfiguration.

@Test
public void shouldGetCycle3AttributeRequestDataFromConfiguration() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionIdBuilder.aSessionId().build();
    String rpEntityId = new Cycle3DTO(sessionId).getRequestIssuerId();
    Response sessionCreatedResponse = createSessionInAwaitingCycle3DataState(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);
    // When
    Cycle3AttributeRequestData actualResponse = getCycle3Data(sessionId);
    // Then
    Cycle3AttributeRequestData expectedResponse = aCycle3AttributeRequestData().withAttributeName(cycle3Attribute.getAttributeName().get()).withRequestIssuerId(rpEntityId).build();
    assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
Also used : Response(javax.ws.rs.core.Response) Cycle3DTO(uk.gov.ida.integrationtest.hub.policy.rest.Cycle3DTO) MatchingProcessDto(uk.gov.ida.hub.policy.domain.MatchingProcessDto) 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 60 with SessionId

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

the class EidasCycle3DataResourceTest method shouldReturnSuccessWhenDataSubmitted.

@Test
public void shouldReturnSuccessWhenDataSubmitted() throws JsonProcessingException {
    final SessionId sessionId = SessionIdBuilder.aSessionId().build();
    final String rpEntityId = new EidasCycle3DTO(sessionId).getRequestIssuerEntityId();
    final String msaEntityId = new EidasCycle3DTO(sessionId).getMatchingServiceAdapterEntityId();
    final Response sessionCreatedResponse = createSessionInEidasAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final Cycle3UserInput cycle3UserInput = new Cycle3UserInput("test-value", "principal-ip-address-seen-by-hub");
    samlEngineStub.setupStubForEidasAttributeQueryRequestGeneration(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
    configStub.setUpStubForMatchingServiceRequest(rpEntityId, msaEntityId);
    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    postCycle3Data(sessionId, cycle3UserInput);
    assertThat(getSessionStateName(sessionId)).isEqualTo(EidasCycle3MatchRequestSentState.class.getName());
}
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) Cycle3UserInput(uk.gov.ida.hub.policy.domain.Cycle3UserInput) EidasCycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.EidasCycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) 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