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