Search in sources :

Example 1 with UserAccountCreationRequestSentState

use of uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState 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)

Example 2 with UserAccountCreationRequestSentState

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

the class UserAccountCreationRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.

@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
    UserAccountCreationRequestSentState state = aUserAccountCreationRequestSentState().build();
    UserAccountCreationRequestSentStateController controller = new UserAccountCreationRequestSentStateController(state, null, null, null, null, null, null);
    ResponseFromMatchingService responseFromMatchingService = new UserAccountCreatedFromMatchingService("issuer-id", "", "", Optional.absent());
    try {
        controller.validateResponse(responseFromMatchingService);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo("Response to request ID [" + state.getRequestId() + "] came from [issuer-id] and was expected to come from [matchingServiceEntityId]");
    }
}
Also used : ResponseFromMatchingService(uk.gov.ida.hub.policy.domain.ResponseFromMatchingService) UserAccountCreatedFromMatchingService(uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState(uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) Test(org.junit.Test)

Example 3 with UserAccountCreationRequestSentState

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInUserAccountCreationRequestSentState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInUserAccountCreationRequestSentState() {
    UserAccountCreationRequestSentState state = UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState().build();
    StateController stateController = new UserAccountCreationRequestSentStateController(state, stateTransitionAction, hubEventLogger, policyConfiguration, levelOfAssuranceValidator, responseFromHubFactory, attributeQueryService);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : StateController(uk.gov.ida.hub.policy.domain.StateController) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)3 UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState (uk.gov.ida.hub.policy.builder.state.UserAccountCreationRequestSentStateBuilder.aUserAccountCreationRequestSentState)2 UserAccountCreatedFromMatchingService (uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService)2 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)1 ResponseFromMatchingService (uk.gov.ida.hub.policy.domain.ResponseFromMatchingService)1 State (uk.gov.ida.hub.policy.domain.State)1 StateController (uk.gov.ida.hub.policy.domain.StateController)1 StateProcessingValidationException (uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException)1 UserAccountCreatedState (uk.gov.ida.hub.policy.domain.state.UserAccountCreatedState)1