Search in sources :

Example 6 with Cycle3MatchRequestSentState

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

the class Cycle3MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.

@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, null, null, null, null, null, transactionsConfigProxy, null, null, null);
    MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId("issuer-id").build();
    try {
        controller.validateResponse(matchFromMatchingService);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo(format("Response to request ID [{0}] came from [issuer-id] and was expected to come from [{1}]", state.getRequestId(), matchingServiceEntityId));
    }
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchFromMatchingServiceBuilder.aMatchFromMatchingService(uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) Test(org.junit.Test)

Example 7 with Cycle3MatchRequestSentState

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

the class Cycle3MatchRequestSentStateControllerTest method responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest.

@Test(expected = StateProcessingValidationException.class)
public void responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, policyConfiguration, mock(LevelOfAssuranceValidator.class), null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(matchingServiceEntityId, "definitelyNotTheSameRequestId", "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
    controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchFromMatchingServiceBuilder.aMatchFromMatchingService(uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) Matchers.anyString(org.mockito.Matchers.anyString) LevelOfAssuranceValidator(uk.gov.ida.hub.policy.validators.LevelOfAssuranceValidator) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 8 with Cycle3MatchRequestSentState

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

the class Cycle3MatchRequestSentStateControllerTest method shouldReturnWaitResponseWhenAskedAndInCycle3MatchRequestSentState.

@Test
public void shouldReturnWaitResponseWhenAskedAndInCycle3MatchRequestSentState() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
    final ResponseProcessingDetails responseProcessingDetails = controller.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.WAIT);
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.Test)

Example 9 with Cycle3MatchRequestSentState

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState() {
    Cycle3MatchRequestSentState state = Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState().build();
    StateController stateController = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, levelOfAssuranceValidator, responseFromHubFactory, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 10 with Cycle3MatchRequestSentState

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

the class AwaitingCycle3DataStateController method handleCycle3DataSubmitted.

@Override
public void handleCycle3DataSubmitted(final String principalIpAddressAsSeenByHub) {
    getHubEventLogger().logCycle3DataObtained(getState().getSessionId(), getState().getRequestIssuerEntityId(), getState().getSessionExpiryTimestamp(), getState().getRequestId(), principalIpAddressAsSeenByHub);
    Cycle3MatchRequestSentState cycle3MatchRequestSentState = new Cycle3MatchRequestSentState(getState().getRequestId(), getState().getRequestIssuerEntityId(), getState().getSessionExpiryTimestamp(), getState().getAssertionConsumerServiceUri(), getState().getSessionId(), getState().getTransactionSupportsEidas(), getState().getIdentityProviderEntityId(), getState().getRelayState().orNull(), getState().getLevelOfAssurance(), getState().isRegistering(), getState().getMatchingServiceEntityId(), getState().getEncryptedMatchingDatasetAssertion(), getState().getAuthnStatementAssertion(), getState().getPersistentId());
    getStateTransitionAction().transitionTo(cycle3MatchRequestSentState);
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)

Aggregations

Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)15 Test (org.junit.Test)14 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)12 Matchers.anyString (org.mockito.Matchers.anyString)10 SessionId (uk.gov.ida.hub.policy.domain.SessionId)10 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)6 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)4 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)3 MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)3 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)3 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)3 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)3 State (uk.gov.ida.hub.policy.domain.State)2 StateTransitionAction (uk.gov.ida.hub.policy.domain.StateTransitionAction)2 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)2 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)2 LevelOfAssuranceValidator (uk.gov.ida.hub.policy.validators.LevelOfAssuranceValidator)2 URI (java.net.URI)1 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)1 AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState (uk.gov.ida.hub.policy.builder.state.AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState)1