use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckHandlerTest method handle_shouldCheckHealthOfAllMatchingServices.
@Test
public void handle_shouldCheckHealthOfAllMatchingServices() throws Exception {
MatchingServiceConfigEntityDataDto firstMatchingService = aMatchingServiceConfigEntityDataDto().withUri(URI.create("/a-matching-service-uri-1")).withEntityId("1").build();
MatchingServiceConfigEntityDataDto secondMatchingService = aMatchingServiceConfigEntityDataDto().withUri(URI.create("/a-matching-service-uri-2")).withEntityId("2").build();
Collection<MatchingServiceConfigEntityDataDto> matchingServiceConfigEntityDatas = asList(firstMatchingService, secondMatchingService);
when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(matchingServiceConfigEntityDatas);
when(matchingServiceHealthChecker.performHealthCheck(any(MatchingServiceConfigEntityDataDto.class))).thenReturn(MatchingServiceHealthCheckResult.healthy(MatchingServiceHealthCheckDetailsBuilder.aMatchingServiceHealthCheckDetails().build()));
AggregatedMatchingServicesHealthCheckResult result = matchingServiceHealthCheckHandler.handle();
verify(matchingServiceHealthChecker).performHealthCheck(firstMatchingService);
verify(matchingServiceHealthChecker).performHealthCheck(secondMatchingService);
assertThat(result.getResults().size()).isEqualTo(2);
}
use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method handle_shouldReturnResponseIdVersionIfDifferentOnesArePresentInResponseIDAndHeaderWithMessageForHealthyMatchingService.
@Test
public void handle_shouldReturnResponseIdVersionIfDifferentOnesArePresentInResponseIDAndHeaderWithMessageForHealthyMatchingService() throws Exception {
final Optional<String> headerVersion = Optional.fromNullable("HEADERVER");
final String idVersion = "IDVER";
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
prepareForHealthyResponse(matchingServiceConfigEntityDataDto, headerVersion);
mockHealthcheckResponseId("healthcheck-response-id-uuid-version-" + idVersion);
MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
assertThat(result.getDetails().getVersionNumber()).isEqualTo(idVersion);
}
use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method handle_shouldExecuteHealthCheckForMatchingServiceWithHealthCheckEnabled.
@Test
public void handle_shouldExecuteHealthCheckForMatchingServiceWithHealthCheckEnabled() {
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withHealthCheckEnabled().build();
prepareForHealthyResponse(matchingServiceConfigEntityDataDto, Optional.absent());
matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
verify(matchingServiceHealthCheckClient, times(1)).sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()));
}
use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method handle_shouldReturnFailureWithMessageForUnhealthyMatchingService.
@Test
public void handle_shouldReturnFailureWithMessageForUnhealthyMatchingService() throws Exception {
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
prepareForResponse(matchingServiceConfigEntityDataDto, RequesterError, Optional.absent());
MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
assertThat(result.isHealthy()).isEqualTo(false);
assertThat(result.getDetails().getDetails()).isEqualTo("responded with non-healthy status");
}
use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method shouldNotReturnVersionIfNotPresentInResponseIdOrHeaderForHealthyMatchingService.
@Test
public void shouldNotReturnVersionIfNotPresentInResponseIdOrHeaderForHealthyMatchingService() throws Exception {
final Optional<String> headerVersion = Optional.absent();
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
prepareForHealthyResponse(matchingServiceConfigEntityDataDto, headerVersion);
mockHealthcheckResponseId("healthcheck-response-id");
MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
assertThat(result.getDetails().getVersionNumber()).isEqualTo("0");
}
Aggregations