Search in sources :

Example 1 with UserAccountCreatedFromMatchingService

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

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

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

the class MatchingServiceResponseService method handleUserAccountCreatedResponseFromMatchingService.

private void handleUserAccountCreatedResponseFromMatchingService(SessionId sessionId, InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto) {
    UserAccountCreatedFromMatchingService userAccountCreatedFromMatchingService = new UserAccountCreatedFromMatchingService(inboundResponseFromMatchingServiceDto.getIssuer(), inboundResponseFromMatchingServiceDto.getInResponseTo(), inboundResponseFromMatchingServiceDto.getUnderlyingMatchingServiceAssertionBlob().get(), inboundResponseFromMatchingServiceDto.getLevelOfAssurance());
    WaitingForMatchingServiceResponseStateController stateController = (WaitingForMatchingServiceResponseStateController) sessionRepository.getStateController(sessionId, WaitingForMatchingServiceResponseState.class);
    stateController.handleUserAccountCreatedResponseFromMatchingService(userAccountCreatedFromMatchingService);
}
Also used : WaitingForMatchingServiceResponseStateController(uk.gov.ida.hub.policy.domain.controller.WaitingForMatchingServiceResponseStateController) UserAccountCreatedFromMatchingService(uk.gov.ida.hub.policy.domain.UserAccountCreatedFromMatchingService) WaitingForMatchingServiceResponseState(uk.gov.ida.hub.policy.domain.state.WaitingForMatchingServiceResponseState)

Aggregations

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