Search in sources :

Example 11 with ResponseProcessingDetails

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

the class MatchingServiceResourcesIntegrationTest method isResponseFromHubReady_shouldReturnFailedStatusWhenAProblemHasOccurredWhilstMatchingCycle3.

@Test
public void isResponseFromHubReady_shouldReturnFailedStatusWhenAProblemHasOccurredWhilstMatchingCycle3() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
    aCycle3AttributeHasBeenSentToPolicyFromTheUser(sessionId, "#1");
    aMatchingServiceFailureResponseHasBeenReceived(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 12 with ResponseProcessingDetails

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

the class MatchingServiceResourcesIntegrationTest method responseProcessingDetails_shouldReturnSuccessResponse_whenNoMatchWithC3Enabled_userAccountCreationAttributesAreFetched.

@Test
public void responseProcessingDetails_shouldReturnSuccessResponse_whenNoMatchWithC3Enabled_userAccountCreationAttributesAreFetched() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
    aCycle3AttributeHasBeenSentToPolicyFromTheUser(sessionId, "#1");
    aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled(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.WAIT);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(UserAccountCreationRequestSentState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) Test(org.junit.Test)

Example 13 with ResponseProcessingDetails

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

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

the class Cycle0And1MatchRequestSentStateControllerTest method shouldReturnWaitResponseWhenAskedAndInCycle0And1MatchRequestSentState.

@Test
public void shouldReturnWaitResponseWhenAskedAndInCycle0And1MatchRequestSentState() {
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
    final ResponseProcessingDetails responseProcessingDetails = controller.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.WAIT);
}
Also used : ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.Test)

Example 15 with ResponseProcessingDetails

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

the class Cycle0And1MatchRequestSentStateControllerTest method responseProcessingDetails_shouldReturnNoMatchStatus_noMatchResponseSentFromMatchingService.

@Test
public void responseProcessingDetails_shouldReturnNoMatchStatus_noMatchResponseSentFromMatchingService() {
    ArgumentCaptor<NoMatchState> argumentCaptor = ArgumentCaptor.forClass(NoMatchState.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID);
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(emptyList());
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
    NoMatchStateController noMatchStateController = new NoMatchStateController(argumentCaptor.getValue(), responseFromHubFactory);
    final ResponseProcessingDetails responseProcessingDetails = noMatchStateController.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_NO_MATCH_RESPONSE_TO_TRANSACTION);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(state.getSessionId());
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)18 SessionId (uk.gov.ida.hub.policy.domain.SessionId)14 URI (java.net.URI)11 Response (javax.ws.rs.core.Response)11 MatchingServiceRequestErrorState (uk.gov.ida.hub.policy.domain.state.MatchingServiceRequestErrorState)6 Matchers.anyString (org.mockito.Matchers.anyString)3 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)3 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)3 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)3 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)2 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)2 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)1 MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)1 MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)1 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)1 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)1 UserAccountCreatedState (uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState)1 UserAccountCreationFailedState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationFailedState)1 IdentityProvidersConfigProxy (uk.gov.ida.hub.policy.proxy.IdentityProvidersConfigProxy)1