use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInIdpSelectedState.
@Test
public void shouldReturnErrorResponseWhenAskedAndInIdpSelectedState() {
IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().build();
StateController stateController = new IdpSelectedStateController(state, hubEventLogger, stateTransitionAction, identityProvidersConfigProxy, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionFactory, matchingServiceConfigProxy);
when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class IdpSelectorTest method buildIdpSelectedState_shouldReturnStateWithNewIdpForIdpSelectedState.
@Test
public void buildIdpSelectedState_shouldReturnStateWithNewIdpForIdpSelectedState() {
IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withRelayState("relay-state").withIdpEntityId("idp-b").withAvailableIdentityProviders(ImmutableList.of(IDP_ENTITY_ID, OTHER_IDP_ENTITY_ID)).withRegistration(true).build();
IdpConfigDto idpConfigDto = new IdpConfigDto(IDP_ENTITY_ID, true, ImmutableList.of(LevelOfAssurance.LEVEL_2, LevelOfAssurance.LEVEL_1));
when(identityProvidersConfigProxy.getIdpConfig("idp-b")).thenReturn(idpConfigDto);
when(transactionsConfigProxy.getLevelsOfAssurance(state.getRequestIssuerEntityId())).thenReturn(asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2));
when(transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId())).thenReturn(state.getMatchingServiceEntityId());
when(identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), state.isRegistering(), REQUESTED_LOA)).thenReturn(asList(IDP_ENTITY_ID, OTHER_IDP_ENTITY_ID));
IdpSelectedState idpSelectedState = IdpSelector.buildIdpSelectedState(state, "idp-b", true, REQUESTED_LOA, transactionsConfigProxy, identityProvidersConfigProxy);
assertThat(idpSelectedState).isEqualToComparingFieldByField(state);
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class IdpSelectorTest method shouldRaiseAnExceptionWhenSelectedIDPDoesNotHaveRequestedLevelOfAssurance.
@Test(expected = StateProcessingValidationException.class)
public void shouldRaiseAnExceptionWhenSelectedIDPDoesNotHaveRequestedLevelOfAssurance() {
IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withIdpEntityId(IDP_ENTITY_ID).withAvailableIdentityProviders(ImmutableList.of(IDP_ENTITY_ID)).build();
when(transactionsConfigProxy.getLevelsOfAssurance(state.getRequestIssuerEntityId())).thenReturn(asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2));
when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(new IdpConfigDto(IDP_ENTITY_ID, true, ImmutableList.of(LevelOfAssurance.LEVEL_1)));
when(identityProvidersConfigProxy.getIdpConfig(OTHER_IDP_ENTITY_ID)).thenReturn(new IdpConfigDto(OTHER_IDP_ENTITY_ID, true, ImmutableList.of(REQUESTED_LOA)));
when(identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), state.isRegistering(), REQUESTED_LOA)).thenReturn(singletonList(OTHER_IDP_ENTITY_ID));
IdpSelector.buildIdpSelectedState(state, IDP_ENTITY_ID, true, REQUESTED_LOA, transactionsConfigProxy, identityProvidersConfigProxy);
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState 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());
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class IdpSelectorTest method shouldRaiseAnExceptionWhenTransactionEntityDoesNotHaveRequestedLevelOfAssurance.
@Test(expected = StateProcessingValidationException.class)
public void shouldRaiseAnExceptionWhenTransactionEntityDoesNotHaveRequestedLevelOfAssurance() {
IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withIdpEntityId(IDP_ENTITY_ID).withAvailableIdentityProviders(ImmutableList.of(IDP_ENTITY_ID)).build();
when(transactionsConfigProxy.getLevelsOfAssurance(state.getRequestIssuerEntityId())).thenReturn(singletonList(LevelOfAssurance.LEVEL_1));
when(identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), state.isRegistering(), REQUESTED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
IdpSelector.buildIdpSelectedState(state, IDP_ENTITY_ID, true, REQUESTED_LOA, transactionsConfigProxy, identityProvidersConfigProxy);
}
Aggregations