use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.
@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, null, null, null, null, null, transactionsConfigProxy, null, null, null);
MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId("issuer-id").build();
try {
controller.validateResponse(matchFromMatchingService);
fail("fail");
} catch (StateProcessingValidationException e) {
assertThat(e.getMessage()).isEqualTo(format("Response to request ID [{0}] came from [issuer-id] and was expected to come from [{1}]", state.getRequestId(), matchingServiceEntityId));
}
}
use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest.
@Test(expected = StateProcessingValidationException.class)
public void responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, policyConfiguration, mock(LevelOfAssuranceValidator.class), null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(matchingServiceEntityId, "definitelyNotTheSameRequestId", "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
}
use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method shouldReturnWaitResponseWhenAskedAndInCycle3MatchRequestSentState.
@Test
public void shouldReturnWaitResponseWhenAskedAndInCycle3MatchRequestSentState() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
final ResponseProcessingDetails responseProcessingDetails = controller.getResponseProcessingDetails();
assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.WAIT);
}
use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState in project verify-hub by alphagov.
the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState.
@Test
public void shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState() {
Cycle3MatchRequestSentState state = Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState().build();
StateController stateController = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, levelOfAssuranceValidator, responseFromHubFactory, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState in project verify-hub by alphagov.
the class AwaitingCycle3DataStateController method handleCycle3DataSubmitted.
@Override
public void handleCycle3DataSubmitted(final String principalIpAddressAsSeenByHub) {
getHubEventLogger().logCycle3DataObtained(getState().getSessionId(), getState().getRequestIssuerEntityId(), getState().getSessionExpiryTimestamp(), getState().getRequestId(), principalIpAddressAsSeenByHub);
Cycle3MatchRequestSentState cycle3MatchRequestSentState = new Cycle3MatchRequestSentState(getState().getRequestId(), getState().getRequestIssuerEntityId(), getState().getSessionExpiryTimestamp(), getState().getAssertionConsumerServiceUri(), getState().getSessionId(), getState().getTransactionSupportsEidas(), getState().getIdentityProviderEntityId(), getState().getRelayState().orNull(), getState().getLevelOfAssurance(), getState().isRegistering(), getState().getMatchingServiceEntityId(), getState().getEncryptedMatchingDatasetAssertion(), getState().getAuthnStatementAssertion(), getState().getPersistentId());
getStateTransitionAction().transitionTo(cycle3MatchRequestSentState);
}
Aggregations