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);
}
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]");
}
}
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);
}
Aggregations