Search in sources :

Example 1 with UserAccountCreatedState

use of uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState in project verify-hub by alphagov.

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInUserAccountCreatedState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInUserAccountCreatedState() {
    UserAccountCreatedState state = UserAccountCreatedStateBuilder.aUserAccountCreatedState().build();
    StateController stateController = new UserAccountCreatedStateController(state, identityProvidersConfigProxy, responseFromHubFactory);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : UserAccountCreatedState(uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 2 with UserAccountCreatedState

use of uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState in project verify-hub by alphagov.

the class UserAccountCreatedStateControllerTest method getPreparedResponse_shouldThrowWhenIdpIsDisabled.

@Test(expected = IdpDisabledException.class)
public void getPreparedResponse_shouldThrowWhenIdpIsDisabled() {
    UserAccountCreatedState state = aUserAccountCreatedState().withIdentityProviderEntityId("disabled-entity-id").build();
    UserAccountCreatedStateController controller = new UserAccountCreatedStateController(state, identityProvidersConfigProxy, null);
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(Matchers.any(String.class), Matchers.anyBoolean(), Matchers.any(LevelOfAssurance.class))).thenReturn(emptyList());
    controller.getPreparedResponse();
}
Also used : LevelOfAssurance(uk.gov.ida.hub.policy.domain.LevelOfAssurance) UserAccountCreatedState(uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState) UserAccountCreatedStateBuilder.aUserAccountCreatedState(uk.gov.ida.hub.policy.builder.state.UserAccountCreatedStateBuilder.aUserAccountCreatedState) Test(org.junit.Test)

Example 3 with UserAccountCreatedState

use of uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState in project verify-hub by alphagov.

the class UserAccountCreationRequestSentStateControllerTest method getNextState_shouldMaintainRelayState.

@Test
public void getNextState_shouldMaintainRelayState() {
    final String relayState = "4x100m";
    UserAccountCreationRequestSentState state = aUserAccountCreationRequestSentState().withRelayState(relayState).build();
    UserAccountCreationRequestSentStateController controller = new UserAccountCreationRequestSentStateController(state, null, hubEventLogger, null, levelOfAssuranceValidator, null, null);
    UserAccountCreatedFromMatchingService userAccountCreatedFromMatchingService = new UserAccountCreatedFromMatchingService("issuer-id", "", "", Optional.absent());
    final State newState = controller.getNextStateForUserAccountCreated(userAccountCreatedFromMatchingService);
    assertThat(newState).isInstanceOf(UserAccountCreatedState.class);
    final UserAccountCreatedState userAccountCreatedState = (UserAccountCreatedState) newState;
    assertThat(userAccountCreatedState.getRelayState()).isNotNull();
    assertThat(userAccountCreatedState.getRelayState().isPresent()).isTrue();
    assertThat(userAccountCreatedState.getRelayState().get()).isEqualTo(relayState);
}
Also used : UserAccountCreatedState(uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState) UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState(uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState) State(uk.gov.ida.hub.policy.domain.State) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) UserAccountCreatedState(uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState) UserAccountCreatedFromMatchingService(uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService) UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState(uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 UserAccountCreatedState (uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState)3 UserAccountCreatedStateBuilder.aUserAccountCreatedState (uk.gov.ida.hub.policy.builder.state.UserAccountCreatedStateBuilder.aUserAccountCreatedState)1 UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState (uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)1 State (uk.gov.ida.hub.policy.domain.State)1 StateController (uk.gov.ida.hub.policy.domain.StateController)1 UserAccountCreatedFromMatchingService (uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService)1 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)1