Search in sources :

Example 71 with SessionId

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

the class MatchingServiceResourcesIntegrationTest method isResponseFromHubReady_shouldTellFrontendToShowErrorPageWhenMSRespondsButSamlEngineThrowsInvalidSamlError.

@Test
public void isResponseFromHubReady_shouldTellFrontendToShowErrorPageWhenMSRespondsButSamlEngineThrowsInvalidSamlError() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    samlEngineRespondsToATranslateAttributeQueryWithAnErrorStatusDto(sessionId);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RESPONSE_PROCESSING_DETAILS_RESOURCE).build(sessionId);
    Response response = getResponse(policy.uri(uri.toASCIIString()));
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseProcessingDetails responseProcessingDetails = response.readEntity(ResponseProcessingDetails.class);
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SHOW_MATCHING_ERROR_PAGE);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(MatchingServiceRequestErrorState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) MatchingServiceRequestErrorState(uk.gov.ida.hub.policy.domain.state.MatchingServiceRequestErrorState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.Test)

Example 72 with SessionId

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

the class MatchingServiceResourcesIntegrationTest method getCycle3AttributeRequestData_shouldReturnExpectedAttributeData.

@Test
public void getCycle3AttributeRequestData_shouldReturnExpectedAttributeData() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    final String cycle3Attribute = aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.CYCLE_3_REQUEST_RESOURCE).build(sessionId);
    Response response = getResponse(policy.uri(uri.toASCIIString()));
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final Cycle3AttributeRequestData attributeData = response.readEntity(Cycle3AttributeRequestData.class);
    assertThat(attributeData.getAttributeName()).isEqualTo(cycle3Attribute);
    assertThat(attributeData.getRequestIssuerId()).isEqualTo(rpEntityId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(AwaitingCycle3DataState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Example 73 with SessionId

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

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

the class EidasAwaitingCycle3DataStateBuilderTest method build.

@Test
public void build() {
    EidasAwaitingCycle3DataState state = EidasAwaitingCycle3DataStateBuilder.anEidasAwaitingCycle3DataState().build();
    assertThat(state.getRequestId()).isEqualTo("requestId");
    assertThat(state.getRequestIssuerEntityId()).isEqualTo("requestIssuerId");
    assertThat(state.getSessionExpiryTimestamp()).isEqualTo(DateTime.now().plusMinutes(10));
    assertThat(state.getAssertionConsumerServiceUri()).isEqualTo(URI.create("assertionConsumerServiceUri"));
    assertThat(state.getSessionId()).isEqualTo(new SessionId("sessionId"));
    assertThat(state.getTransactionSupportsEidas()).isEqualTo(true);
    assertThat(state.getIdentityProviderEntityId()).isEqualTo("identityProviderEntityId");
    assertThat(state.getMatchingServiceEntityId()).isEqualTo("matchingServiceAdapterEntityId");
    assertThat(state.getRelayState()).isEqualTo(Optional.of("relayState"));
    assertThat(state.getPersistentId()).isEqualTo(new PersistentId("nameId"));
    assertThat(state.getLevelOfAssurance()).isEqualTo(LevelOfAssurance.LEVEL_2);
    assertThat(state.getEncryptedIdentityAssertion()).isEqualTo("encryptedIdentityAssertion");
}
Also used : EidasAwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) Test(org.junit.Test)

Example 75 with SessionId

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

the class EidasCycle0And1MatchRequestSentStateBuilderTest method build.

@Test
public void build() {
    EidasCycle0And1MatchRequestSentState state = EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState().build();
    assertThat(state.getRequestId()).isEqualTo("requestId");
    assertThat(state.getIdentityProviderEntityId()).isEqualTo("identityProviderEntityId");
    assertThat(state.getSessionExpiryTimestamp()).isEqualTo(DateTime.now().plusMinutes(10));
    assertThat(state.getRelayState()).isEqualTo(Optional.absent());
    assertThat(state.getRequestIssuerEntityId()).isEqualTo("requestIssuerId");
    assertThat(state.getEncryptedIdentityAssertion()).isEqualTo("encryptedIdentityAssertion");
    assertThat(state.getAssertionConsumerServiceUri()).isEqualTo(URI.create("assertionConsumerServiceUri"));
    assertThat(state.getMatchingServiceAdapterEntityId()).isEqualTo("matchingServiceAdapterEntityId");
    assertThat(state.getSessionId()).isEqualTo(new SessionId("sessionId"));
    assertThat(state.getIdpLevelOfAssurance()).isEqualTo(LevelOfAssurance.LEVEL_2);
    assertThat(state.getPersistentId()).isEqualTo(new PersistentId("default-name-id"));
    assertThat(state.getTransactionSupportsEidas()).isEqualTo(true);
}
Also used : EidasCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) 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