use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceHealthCheckerResponseDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method prepareForResponse.
private void prepareForResponse(MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto, MatchingServiceIdaStatus status, Optional<String> msaVersion) {
when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenReturn(new SamlMessageDto("<saml/>"));
final MatchingServiceHealthCheckerResponseDto inboundResponseFromMatchingServiceDto = anInboundResponseFromMatchingServiceDto().withStatus(status).build();
when(matchingServiceHealthCheckClient.sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()))).thenReturn(new MatchingServiceHealthCheckResponseDto(Optional.of("<saml/>"), msaVersion));
when(samlEngineProxy.translateHealthcheckMatchingServiceResponse(any())).thenReturn(inboundResponseFromMatchingServiceDto);
}
use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceHealthCheckerResponseDto in project verify-hub by alphagov.
the class MatchingServiceHealthChecker method isHealthyResponse.
private boolean isHealthyResponse(final MatchingServiceHealthCheckResponseDto responseDto, final URI matchingServiceUri) {
if (!responseDto.getResponse().isPresent()) {
return false;
}
String exceptionMessage = format("Matching service health check failed for URI {0}", matchingServiceUri);
try {
// Saml-engine expects the saml to be base64 encoded
final SamlMessageDto samlMessageDto = new SamlMessageDto(Base64.encodeAsString(responseDto.getResponse().get()));
final MatchingServiceHealthCheckerResponseDto responseFromMatchingService = samlEngineProxy.translateHealthcheckMatchingServiceResponse(samlMessageDto);
if (responseFromMatchingService.getStatus() != MatchingServiceIdaStatus.Healthy) {
return false;
}
} catch (ApplicationException e) {
eventLogger.logException(e, exceptionMessage);
return false;
} catch (RuntimeException e) {
LOG.warn(format("Matching service health check failed for URI {0}", matchingServiceUri), e);
return false;
}
return true;
}
Aggregations