use of uk.gov.ida.hub.policy.domain.state.SessionStartedState in project verify-hub by alphagov.
the class SessionRepositoryTest method getState_shouldThrowTimeoutStateException_whenStateRequestedIsNotTimeoutStateAndAlreadyTimeout.
@Test(expected = SessionTimeoutException.class)
public void getState_shouldThrowTimeoutStateException_whenStateRequestedIsNotTimeoutStateAndAlreadyTimeout() {
DateTime now = DateTime.now();
DateTimeFreezer.freezeTime(now);
SessionStartedState sessionStartedState = aSessionStartedState().withSessionExpiryTimestamp(now).build();
SessionId sessionId = sessionRepository.createSession(sessionStartedState);
DateTimeFreezer.freezeTime(now.plusMinutes(3));
try {
sessionRepository.getStateController(sessionId, SessionStartedState.class);
} catch (Exception e) {
}
// it is set to timed out now
sessionRepository.getStateController(sessionId, SessionStartedState.class);
}
use of uk.gov.ida.hub.policy.domain.state.SessionStartedState in project verify-hub by alphagov.
the class SessionRepositoryTest method getState_shouldThrowTimeoutStateException_whenStateRequestedIsNotTimeoutStateAndTimeout.
@Test(expected = SessionTimeoutException.class)
public void getState_shouldThrowTimeoutStateException_whenStateRequestedIsNotTimeoutStateAndTimeout() {
DateTime now = DateTime.now();
DateTimeFreezer.freezeTime(now);
SessionStartedState sessionStartedState = aSessionStartedState().withSessionExpiryTimestamp(now).build();
SessionId sessionId = sessionRepository.createSession(sessionStartedState);
DateTimeFreezer.freezeTime(now.plusMinutes(3));
sessionRepository.getStateController(sessionId, SessionStartedState.class);
}
use of uk.gov.ida.hub.policy.domain.state.SessionStartedState in project verify-hub by alphagov.
the class SessionRepositoryTest method shouldThrowExceptionIfStateIsNotWhatIsExpected.
@Test(expected = InvalidSessionStateException.class)
public void shouldThrowExceptionIfStateIsNotWhatIsExpected() {
SessionId expectedSessionId = aSessionId().build();
SessionStartedState sessionStartedState = aSessionStartedState().withSessionExpiryTimestamp(defaultSessionExpiry).withSessionId(expectedSessionId).build();
SessionId sessionId = sessionRepository.createSession(sessionStartedState);
sessionRepository.getStateController(sessionId, IdpSelectedState.class);
}
use of uk.gov.ida.hub.policy.domain.state.SessionStartedState in project verify-hub by alphagov.
the class SessionRepositoryTest method getLevelOfAssuranceFromIdp.
@Test
public void getLevelOfAssuranceFromIdp() {
SessionStartedState state = aSessionStartedState().build();
SessionId sessionId = sessionRepository.createSession(state);
assertThat(sessionRepository.getLevelOfAssuranceFromIdp(sessionId)).isEqualTo(Optional.absent());
}
use of uk.gov.ida.hub.policy.domain.state.SessionStartedState in project verify-hub by alphagov.
the class IdpSelectorTest method buildIdpSelectedState_shouldReturnStateWithSessionStartedState.
@Test
public void buildIdpSelectedState_shouldReturnStateWithSessionStartedState() {
SessionStartedState state = SessionStartedStateBuilder.aSessionStartedState().build();
when(transactionsConfigProxy.getLevelsOfAssurance(state.getRequestIssuerEntityId())).thenReturn(asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2));
when(transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId())).thenReturn("matching-service-id");
when(identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), true, REQUESTED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
IdpSelectedState idpSelectedState = IdpSelector.buildIdpSelectedState(state, IDP_ENTITY_ID, true, REQUESTED_LOA, transactionsConfigProxy, identityProvidersConfigProxy);
assertThat(idpSelectedState.getRelayState()).isEqualTo(state.getRelayState());
assertThat(idpSelectedState.getIdpEntityId()).isEqualTo(IDP_ENTITY_ID);
assertThat(idpSelectedState.getRequestIssuerEntityId()).isEqualTo(state.getRequestIssuerEntityId());
assertThat(idpSelectedState.getAvailableIdentityProviderEntityIds()).isEqualTo(singletonList(IDP_ENTITY_ID));
assertThat(idpSelectedState.getMatchingServiceEntityId()).isEqualTo("matching-service-id");
assertThat(idpSelectedState.getForceAuthentication()).isEqualTo(state.getForceAuthentication());
assertThat(idpSelectedState.getLevelsOfAssurance()).containsSequence(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2);
assertThat(idpSelectedState.getSessionExpiryTimestamp()).isEqualTo(state.getSessionExpiryTimestamp());
}
Aggregations