use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method shouldReturnReportWhenHubFailsToPerformHealthCheck.
@Test
public void shouldReturnReportWhenHubFailsToPerformHealthCheck() {
final String expectedFailureDetails = "no response";
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenReturn(new SamlMessageDto("<saml/>"));
when(matchingServiceHealthCheckClient.sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()))).thenReturn(new MatchingServiceHealthCheckResponseDto(Optional.empty()));
MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
assertThat(result.isHealthy()).isFalse();
assertThat(result.getDetails()).isEqualToComparingOnlyGivenFields(aMatchingServiceHealthCheckDetails().withDetails(expectedFailureDetails).build(), "details");
}
use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method shouldReturnFailureWithMessageForMatchingServiceThatCannotBeTransformed.
@Test
public void shouldReturnFailureWithMessageForMatchingServiceThatCannotBeTransformed() {
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenReturn(new SamlMessageDto("<saml/>"));
when(matchingServiceHealthCheckClient.sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()))).thenReturn(new MatchingServiceHealthCheckResponseDto(Optional.of("<saml/>")));
when(samlEngineProxy.translateHealthcheckMatchingServiceResponse(any())).thenThrow(ApplicationException.createAuditedException(ExceptionType.INVALID_SAML, UUID.randomUUID()));
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.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method shouldLogExceptionsWhenAFailureOccursInTranslatingHealthCheckRequest.
@Test
public void shouldLogExceptionsWhenAFailureOccursInTranslatingHealthCheckRequest() {
String uri = "http://random";
ApplicationException unauditedException = ApplicationException.createUnauditedException(ExceptionType.INVALID_SAML, UUID.randomUUID());
when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenReturn(new SamlMessageDto("<saml/>"));
when(samlEngineProxy.translateHealthcheckMatchingServiceResponse(any())).thenThrow(unauditedException);
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withUri(uri).build();
when(matchingServiceHealthCheckClient.sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()))).thenReturn(new MatchingServiceHealthCheckResponseDto(Optional.of("<saml/>")));
matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
verify(eventLogger).logException(unauditedException, MessageFormat.format("Matching service health check failed for URI {0}", uri));
}
Aggregations