Search in sources :

Example 1 with AwaitingCycle3DataState

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

the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldGetAwaitingCycle3DataStateWhenTransactionSupportsCycle3.

@Test
public void getNextState_shouldGetAwaitingCycle3DataStateWhenTransactionSupportsCycle3() {
    // Given
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(matchingProcess);
    when(matchingProcess.getAttributeName()).thenReturn(Optional.of("somestring"));
    // When
    final State nextState = controller.getNextStateForNoMatch();
    // Then
    assertThat(nextState).isInstanceOf(AwaitingCycle3DataState.class);
    assertThat(((AwaitingCycle3DataState) nextState).getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
    verify(transactionsConfigProxy, times(0)).getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID);
}
Also used : AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) SuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState) Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) State(uk.gov.ida.hub.policy.domain.State) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) Test(org.junit.Test)

Example 2 with AwaitingCycle3DataState

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

the class AwaitingCycle3DataStateControllerTest method setUpAwaitingCycle3DataStateController.

private AwaitingCycle3DataStateController setUpAwaitingCycle3DataStateController(String requestId, SessionId sessionId) {
    final String transactionEntityId = "some-transaction-entity-id";
    final DateTime sessionExpiryTime = DateTime.now().plusMinutes(1);
    AwaitingCycle3DataState state = anAwaitingCycle3DataState().withSessionId(sessionId).withTransactionEntityId(transactionEntityId).withSessionExpiryTime(sessionExpiryTime).withRequestId(requestId).build();
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new Duration(600L));
    final AwaitingCycle3DataStateController awaitingCycle3DataStateController = new AwaitingCycle3DataStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionsFactory, matchingServiceConfigProxy);
    when(matchingServiceConfigProxy.getMatchingService(state.getMatchingServiceEntityId())).thenReturn(aMatchingServiceConfigEntityDataDto().build());
    return awaitingCycle3DataStateController;
}
Also used : AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState(uk.gov.ida.hub.policy.builder.state.AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) Duration(org.joda.time.Duration) DateTime(org.joda.time.DateTime)

Example 3 with AwaitingCycle3DataState

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

the class AwaitingCycle3DataStateControllerTest method shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived.

@Test
public void shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived() throws Exception {
    final SessionId sessionId = SessionId.createNewSessionId();
    AwaitingCycle3DataState state = anAwaitingCycle3DataState().withSessionId(sessionId).build();
    AwaitingCycle3DataStateController controller = new AwaitingCycle3DataStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionsFactory, matchingServiceConfigProxy);
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
    ArgumentCaptor<Cycle3MatchRequestSentState> argumentCaptor = ArgumentCaptor.forClass(Cycle3MatchRequestSentState.class);
    when(matchingServiceConfigProxy.getMatchingService(state.getMatchingServiceEntityId())).thenReturn(aMatchingServiceConfigEntityDataDto().build());
    controller.handleCycle3DataSubmitted("principalIpAsSeenByHub");
    verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
    final Cycle3MatchRequestSentState cycle3MatchRequestSentState = argumentCaptor.getValue();
    assertThat(cycle3MatchRequestSentState.getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
}
Also used : AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState(uk.gov.ida.hub.policy.builder.state.AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionIdBuilder.aSessionId(uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId) HasSessionId.hasSessionId(uk.gov.ida.hub.policy.matchers.HasSessionId.hasSessionId) Test(org.junit.Test)

Example 4 with AwaitingCycle3DataState

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState.

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

Aggregations

AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)4 Test (org.junit.Test)3 AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState (uk.gov.ida.hub.policy.builder.state.AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState)2 DateTime (org.joda.time.DateTime)1 Duration (org.joda.time.Duration)1 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)1 Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState)1 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)1 SessionId (uk.gov.ida.hub.policy.domain.SessionId)1 State (uk.gov.ida.hub.policy.domain.State)1 StateController (uk.gov.ida.hub.policy.domain.StateController)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)1 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)1 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)1 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)1 HasSessionId.hasSessionId (uk.gov.ida.hub.policy.matchers.HasSessionId.hasSessionId)1