use of uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException 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.exception.StateProcessingValidationException 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.exception.StateProcessingValidationException in project verify-hub by alphagov.
the class LevelOfAssuranceValidatorTest method validate_shouldThrowExceptionIfLevelOfAssuranceFromMatchingServiceDoesNotExist.
@Test
public void validate_shouldThrowExceptionIfLevelOfAssuranceFromMatchingServiceDoesNotExist() throws Exception {
LevelOfAssurance levelOfAssurance = LevelOfAssurance.LEVEL_2;
try {
levelOfAssuranceValidator.validate(Optional.<LevelOfAssurance>absent(), levelOfAssurance);
fail("fail");
} catch (StateProcessingValidationException e) {
assertThat(e.getMessage()).isEqualTo(StateProcessingValidationException.noLevelOfAssurance().getMessage());
}
}
use of uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.
@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
final String responseIssuerId = "wrong issuer";
MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId(responseIssuerId).build();
try {
controller.validateResponse(matchFromMatchingService);
fail("fail");
} catch (StateProcessingValidationException e) {
assertThat(e.getMessage()).isEqualTo(format("Response to request ID [requestId] came from [{0}] and was expected to come from [{1}]", responseIssuerId, MATCHING_SERVICE_ENTITY_ID));
}
}
Aggregations