use of uk.gov.ida.hub.policy.domain.IdpConfigDto 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.IdpConfigDto 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.IdpConfigDto in project verify-hub by alphagov.
the class IdpSelectorTest method setUp.
@Before
public void setUp() {
IdpConfigDto idpConfigDto = new IdpConfigDto(IDP_ENTITY_ID, true, ImmutableList.of(LevelOfAssurance.LEVEL_2, LevelOfAssurance.LEVEL_1));
when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(idpConfigDto);
}
use of uk.gov.ida.hub.policy.domain.IdpConfigDto in project verify-hub by alphagov.
the class IdpSelector method buildIdpSelectedState.
public static IdpSelectedState buildIdpSelectedState(IdpSelectingState state, String idpEntityId, boolean registering, LevelOfAssurance requestedLoa, TransactionsConfigProxy transactionsConfigProxy, IdentityProvidersConfigProxy identityProvidersConfigProxy) {
List<LevelOfAssurance> levelsOfAssuranceForTransaction = transactionsConfigProxy.getLevelsOfAssurance(state.getRequestIssuerEntityId());
if (!levelsOfAssuranceForTransaction.contains(requestedLoa)) {
throw StateProcessingValidationException.requestedLevelOfAssuranceUnsupportedByTransactionEntity(state.getRequestIssuerEntityId(), levelsOfAssuranceForTransaction, requestedLoa);
}
List<String> availableIdentityProviderEntityIdsForLoa = identityProvidersConfigProxy.getEnabledIdentityProviders(state.getRequestIssuerEntityId(), registering, requestedLoa);
checkValidIdentityProvider(idpEntityId, availableIdentityProviderEntityIdsForLoa, state);
IdpConfigDto idpConfig = identityProvidersConfigProxy.getIdpConfig(idpEntityId);
final List<LevelOfAssurance> idpLevelsOfAssurance = idpConfig.getSupportedLevelsOfAssurance();
List<LevelOfAssurance> levelsOfAssuranceForTransactionSupportedByIdp = levelsOfAssuranceForTransaction.stream().filter(idpLevelsOfAssurance::contains).collect(Collectors.toList());
String matchingServiceEntityId = transactionsConfigProxy.getMatchingServiceEntityId(state.getRequestIssuerEntityId());
return new IdpSelectedState(state.getRequestId(), idpEntityId, matchingServiceEntityId, levelsOfAssuranceForTransactionSupportedByIdp, idpConfig.getUseExactComparisonType(), state.getForceAuthentication().orNull(), state.getAssertionConsumerServiceUri(), state.getRequestIssuerEntityId(), state.getRelayState().orNull(), state.getSessionExpiryTimestamp(), registering, requestedLoa, state.getSessionId(), availableIdentityProviderEntityIdsForLoa, state.getTransactionSupportsEidas());
}
use of uk.gov.ida.hub.policy.domain.IdpConfigDto 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);
}
Aggregations