use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class IdpSelectorTest method shouldRaiseAnExceptionWhenSelectedIDPDoesNotExist.
@Test(expected = StateProcessingValidationException.class)
public void shouldRaiseAnExceptionWhenSelectedIDPDoesNotExist() {
IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withIdpEntityId(IDP_ENTITY_ID).withAvailableIdentityProviders(ImmutableList.of(IDP_ENTITY_ID)).build();
when(identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), state.isRegistering(), REQUESTED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
IdpSelector.buildIdpSelectedState(state, "another-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_shouldReturnStateWithIdpSelectedState.
@Test
public void buildIdpSelectedState_shouldReturnStateWithIdpSelectedState() {
IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withRelayState("relay-state").withIdpEntityId(IDP_ENTITY_ID).withRegistration(true).withAvailableIdentityProviders(ImmutableList.of(IDP_ENTITY_ID)).withRegistration(true).build();
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(singletonList(IDP_ENTITY_ID));
IdpSelectedState idpSelectedState = IdpSelector.buildIdpSelectedState(state, IDP_ENTITY_ID, 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 shouldRaiseAnExceptionWhenSelectedIDPDoesNotHaveSupportedLevelsOfAssurance.
@Test(expected = StateProcessingValidationException.class)
public void shouldRaiseAnExceptionWhenSelectedIDPDoesNotHaveSupportedLevelsOfAssurance() {
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()));
when(identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), state.isRegistering(), REQUESTED_LOA)).thenReturn(emptyList());
IdpSelector.buildIdpSelectedState(state, IDP_ENTITY_ID, true, LevelOfAssurance.LEVEL_2, transactionsConfigProxy, identityProvidersConfigProxy);
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class TestSessionResourceHelper method createSessionInIdpSelectedState.
public static Response createSessionInIdpSelectedState(SessionId sessionId, String issuerId, String idpEntityId, Client client, URI uri, boolean transactionSupportsEidas) {
IdpSelectedState idpSelectedState = anIdpSelectedState().withRequestIssuerEntityId(issuerId).withIdpEntityId(idpEntityId).withSessionId(sessionId).withRegistration(true).withTransactionSupportsEidas(transactionSupportsEidas).build();
TestSessionDto testSessionDto = new TestSessionDto(sessionId, idpSelectedState.getRequestId(), idpSelectedState.getSessionExpiryTimestamp(), idpSelectedState.getIdpEntityId(), null, idpSelectedState.getRelayState().orNull(), idpSelectedState.getRequestIssuerEntityId(), idpSelectedState.getMatchingServiceEntityId(), idpSelectedState.getAssertionConsumerServiceUri(), idpSelectedState.getLevelsOfAssurance(), idpSelectedState.getUseExactComparisonType(), idpSelectedState.isRegistering(), idpSelectedState.getRequestedLoa(), idpSelectedState.getForceAuthentication().orNull(), idpSelectedState.getAvailableIdentityProviderEntityIds(), idpSelectedState.getTransactionSupportsEidas());
return client.target(uri).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(testSessionDto));
}
use of uk.gov.ida.hub.policy.domain.state.IdpSelectedState in project verify-hub by alphagov.
the class AuthnFailedErrorStateController method handleIdpSelected.
@Override
public void handleIdpSelected(String idpEntityId, String principalIpAddress, boolean registering, LevelOfAssurance requestedLoa) {
IdpSelectedState idpSelectedState = IdpSelector.buildIdpSelectedState(state, idpEntityId, registering, requestedLoa, transactionsConfigProxy, identityProvidersConfigProxy);
stateTransitionAction.transitionTo(idpSelectedState);
hubEventLogger.logIdpSelectedEvent(idpSelectedState, principalIpAddress);
}
Aggregations