Search in sources :

Example 86 with SessionId

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

the class MatchingServiceResourcesIntegrationTest method isResponseFromHubReady_shouldThrowExceptionWhenMatchingServiceWaitPeriodHasBeenExceeded.

@Test
public void isResponseFromHubReady_shouldThrowExceptionWhenMatchingServiceWaitPeriodHasBeenExceeded() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    theMatchingServiceResponseTimeoutHasBeenExceeded();
    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 87 with SessionId

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

the class RpErrorResponseFromHubIntegrationTest method shouldGenerateAnErrorAuthnResponseFromHub.

@Test
public void shouldGenerateAnErrorAuthnResponseFromHub() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    SamlMessageDto samlMessageDto = new SamlMessageDto("saml");
    samlEngineStub.setUpStubForErrorResponseGenerate(samlMessageDto);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RP_ERROR_RESPONSE_RESOURCE).build(sessionId.getSessionId());
    Response response = get(uri);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = response.readEntity(AuthnResponseFromHubContainerDto.class);
    assertThat(authnResponseFromHubContainerDto.getSamlResponse()).isEqualTo(samlMessageDto.getSamlMessage());
}
Also used : Response(javax.ws.rs.core.Response) AuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto) SamlMessageDto(uk.gov.ida.hub.policy.contracts.SamlMessageDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Example 88 with SessionId

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

the class SessionResourceIntegrationTest method getSessionShouldFailWhenSessionDoesNotExist.

@Test
public void getSessionShouldFailWhenSessionDoesNotExist() {
    SessionId invalidSessionId = SessionId.createNewSessionId();
    URI uri = UriBuilder.fromUri(Urls.PolicyUrls.SESSION_RESOURCE_ROOT).path(Urls.SharedUrls.SESSION_ID_PARAM_PATH).build(invalidSessionId);
    checkException(get(uri), ExceptionType.SESSION_NOT_FOUND);
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Example 89 with SessionId

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

the class SessionResourceIntegrationTest method shouldUpdateSessionStateAndSendAnAttributeQueryRequestWhenASuccessResponseIsReceivedFromIdp.

@Test
public void shouldUpdateSessionStateAndSendAnAttributeQueryRequestWhenASuccessResponseIsReceivedFromIdp() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionId.createNewSessionId();
    Response sessionCreatedResponse = TestSessionResourceHelper.createSessionInIdpSelectedState(sessionId, rpEntityId, idpEntityId, client, policy.uri(UriBuilder.fromPath(TEST_SESSION_RESOURCE_PATH + IDP_SELECTED_STATE).build().toASCIIString()));
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    LevelOfAssurance loaAchieved = LevelOfAssurance.LEVEL_2;
    samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.successResponse(idpEntityId, loaAchieved));
    samlEngineStub.setupStubForAttributeQueryRequest(anAttributeQueryContainerDto().build());
    configStub.setUpStubForMatchingServiceRequest(idpEntityId, IdpSelectedStateBuilder.anIdpSelectedState().build().getMatchingServiceEntityId());
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    // When
    URI idpResponseUri = UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_RESPONSE_RESOURCE).build(sessionId);
    Response response = client.target(policy.uri(idpResponseUri.toASCIIString())).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(aSamlAuthnResponseContainerDto().withSessionId(sessionId).build()));
    // Then
    ResponseAction expectedResult = ResponseAction.success(sessionId, true, loaAchieved);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseAction actualResult = response.readEntity(ResponseAction.class);
    assertThat(actualResult).isEqualToComparingFieldByField(expectedResult);
    assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle0And1MatchRequestSentState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) LevelOfAssurance(uk.gov.ida.hub.policy.domain.LevelOfAssurance) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Example 90 with SessionId

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

the class SessionTimeoutIntegrationTests method selectIdpShouldReturnErrorWhenSessionDoesNotExistInPolicy.

@Test
public void selectIdpShouldReturnErrorWhenSessionDoesNotExistInPolicy() {
    final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    System.setOut(new PrintStream(outContent));
    SessionId sessionId = SessionId.createNewSessionId();
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).buildFromEncoded(sessionId);
    confirmError(policy.uri(uri.getPath()), new IdpSelected(STUB_IDP_ONE, "some-ip-address", REGISTERING, REQUESTED_LOA), ExceptionType.SESSION_NOT_FOUND);
    assertThatEventEmitterWritesToStandardOutput(outContent);
    System.setOut(System.out);
}
Also used : PrintStream(java.io.PrintStream) IdpSelected(uk.gov.ida.hub.policy.domain.IdpSelected) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) 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