Search in sources :

Example 11 with SessionStartedState

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

the class SessionRepositoryTest method stateTransitionAction_shouldUpdateDatastore.

@Test
public void stateTransitionAction_shouldUpdateDatastore() {
    SessionStartedState sessionStartedState = aSessionStartedState().withSessionExpiryTimestamp(defaultSessionExpiry).build();
    SessionId sessionId = sessionRepository.createSession(sessionStartedState);
    sessionRepository.getStateController(sessionId, SessionStartedState.class);
    verify(controllerFactory).build(eq(sessionStartedState), stateTransitionActionArgumentCaptor.capture());
    TestState state = new TestState();
    stateTransitionActionArgumentCaptor.getValue().transitionTo(state);
    assertThat(dataStore.get(sessionId)).isEqualTo((State) state);
}
Also used : SessionIdBuilder.aSessionId(uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId) SessionStartedStateBuilder.aSessionStartedState(uk.gov.ida.hub.policy.builder.state.SessionStartedStateBuilder.aSessionStartedState) SessionStartedState(uk.gov.ida.hub.policy.domain.state.SessionStartedState) Test(org.junit.Test)

Example 12 with SessionStartedState

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInSessionStartedState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInSessionStartedState() {
    SessionStartedState state = SessionStartedStateBuilder.aSessionStartedState().build();
    StateController stateController = new SessionStartedStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, identityProvidersConfigProxy);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : StateController(uk.gov.ida.hub.policy.domain.StateController) SessionStartedState(uk.gov.ida.hub.policy.domain.state.SessionStartedState) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Aggregations

SessionStartedState (uk.gov.ida.hub.policy.domain.state.SessionStartedState)12 Test (org.junit.Test)11 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)9 SessionStartedStateBuilder.aSessionStartedState (uk.gov.ida.hub.policy.builder.state.SessionStartedStateBuilder.aSessionStartedState)9 DateTime (org.joda.time.DateTime)5 SessionTimeoutException (uk.gov.ida.hub.policy.exception.SessionTimeoutException)3 InvalidSessionStateException (uk.gov.ida.hub.policy.exception.InvalidSessionStateException)2 Duration (org.joda.time.Duration)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)1 SessionId (uk.gov.ida.hub.policy.domain.SessionId)1 StateController (uk.gov.ida.hub.policy.domain.StateController)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1 TimeoutState (uk.gov.ida.hub.policy.domain.state.TimeoutState)1