use of uk.gov.ida.hub.policy.domain.State in project verify-hub by alphagov.
the class CountriesService method setSelectedCountry.
public void setSelectedCountry(SessionId sessionId, String countryCode) {
ensureTransactionSupportsEidas(sessionId);
List<EidasCountryDto> supportedCountries = getCountries(sessionId);
Optional<EidasCountryDto> selectedCountry = supportedCountries.stream().filter(country -> country.getSimpleId().equals(countryCode)).findFirst();
if (!selectedCountry.isPresent()) {
throw new EidasCountryNotSupportedException(sessionId, countryCode);
}
Class<? extends State> expectedStateClass = SessionStartedState.class;
if (sessionRepository.isSessionInState(sessionId, CountrySelectedState.class)) {
expectedStateClass = CountrySelectedState.class;
}
CountrySelectingStateController countrySelectingStateController = (CountrySelectingStateController) sessionRepository.getStateController(sessionId, expectedStateClass);
countrySelectingStateController.selectCountry(selectedCountry.get().getEntityId());
}
use of uk.gov.ida.hub.policy.domain.State in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldReturnNoMatchStateWhenTransactionDoesNotSupportCycle3AndMatchingServiceReturnsNoMatchAndUserAccountCreationIsDisabled.
@Test
public void getNextState_shouldReturnNoMatchStateWhenTransactionDoesNotSupportCycle3AndMatchingServiceReturnsNoMatchAndUserAccountCreationIsDisabled() throws Exception {
// Given
when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(Collections.emptyList());
// When
final State nextState = controller.getNextStateForNoMatch();
// Then
assertThat(nextState).isInstanceOf(NoMatchState.class);
}
use of uk.gov.ida.hub.policy.domain.State in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldGetAwaitingCycle3DataStateWhenTransactionSupportsCycle3.
@Test
public void getNextState_shouldGetAwaitingCycle3DataStateWhenTransactionSupportsCycle3() {
// Given
when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(matchingProcess);
when(matchingProcess.getAttributeName()).thenReturn(Optional.of("somestring"));
// When
final State nextState = controller.getNextStateForNoMatch();
// Then
assertThat(nextState).isInstanceOf(AwaitingCycle3DataState.class);
assertThat(((AwaitingCycle3DataState) nextState).getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
verify(transactionsConfigProxy, times(0)).getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID);
}
use of uk.gov.ida.hub.policy.domain.State in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method getNextStateForNoMatch_shouldReturnNoMatchWhenNoAttributesArePresent.
@Test
public void getNextStateForNoMatch_shouldReturnNoMatchWhenNoAttributesArePresent() {
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
ImmutableList<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of();
when(transactionsConfigProxy.getUserAccountCreationAttributes("request issuer id")).thenReturn(userAccountCreationAttributes);
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, null, null, null, transactionsConfigProxy, null, null, null);
State nextState = controller.getNextStateForNoMatch();
assertThat(nextState).isInstanceOf(NoMatchState.class);
}
use of uk.gov.ida.hub.policy.domain.State in project verify-hub by alphagov.
the class EidasCycle0And1MatchRequestSentStateControllerTest method shouldReturnEidasAwaitingCycle3DataState.
@Test
public void shouldReturnEidasAwaitingCycle3DataState() {
when(transactionsConfigProxy.getMatchingProcess(state.getRequestIssuerEntityId())).thenReturn(new MatchingProcess(Optional.of("cycle3AttributeName")));
doNothing().when(hubEventLogger).logWaitingForCycle3AttributesEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
EidasAwaitingCycle3DataState expectedState = new EidasAwaitingCycle3DataState(state.getRequestId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getAssertionConsumerServiceUri(), state.getSessionId(), state.getTransactionSupportsEidas(), state.getIdentityProviderEntityId(), state.getMatchingServiceAdapterEntityId(), state.getRelayState(), state.getPersistentId(), state.getIdpLevelOfAssurance(), state.getEncryptedIdentityAssertion());
State actualState = eidasCycle0And1MatchRequestSentStateController.getNextStateForNoMatch();
assertThat(actualState).isEqualTo(expectedState);
}
Aggregations