Search in sources :

Example 11 with IdpSelectedState

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);
}
Also used : IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) Test(org.junit.Test)

Example 12 with IdpSelectedState

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);
}
Also used : IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) Test(org.junit.Test)

Example 13 with IdpSelectedState

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);
}
Also used : IdpConfigDto(uk.gov.ida.hub.policy.domain.IdpConfigDto) IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) Test(org.junit.Test)

Example 14 with IdpSelectedState

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));
}
Also used : IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) IdpSelectedStateBuilder.anIdpSelectedState(uk.gov.ida.hub.policy.builder.state.IdpSelectedStateBuilder.anIdpSelectedState)

Example 15 with IdpSelectedState

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);
}
Also used : IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState)

Aggregations

IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)17 Test (org.junit.Test)10 IdpConfigDto (uk.gov.ida.hub.policy.domain.IdpConfigDto)4 IdpSelectedStateBuilder.anIdpSelectedState (uk.gov.ida.hub.policy.builder.state.IdpSelectedStateBuilder.anIdpSelectedState)2 EventDetailsKey (uk.gov.ida.eventsink.EventDetailsKey)1 SamlRequestDto (uk.gov.ida.hub.policy.contracts.SamlRequestDto)1 AuthnRequestFromHubContainerDto (uk.gov.ida.hub.policy.domain.AuthnRequestFromHubContainerDto)1 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)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 SessionStartedState (uk.gov.ida.hub.policy.domain.state.SessionStartedState)1 AuthnRequestFromHubContainerDtoBuilder.anAuthnRequestFromHubContainerDto (uk.gov.ida.integrationtest.hub.policy.builders.AuthnRequestFromHubContainerDtoBuilder.anAuthnRequestFromHubContainerDto)1