Search in sources :

Example 16 with MatchingServiceConfigEntityDataDto

use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.

the class MatchingServiceHealthCheckHandlerTest method handle_shouldRemoveDuplicatesFromMatchingServiceList.

@Test
public void handle_shouldRemoveDuplicatesFromMatchingServiceList() {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().withTransactionEntityId("1").build();
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto2 = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().withTransactionEntityId("2").build();
    when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(asList(matchingServiceConfigEntityDataDto, matchingServiceConfigEntityDataDto2));
    matchingServiceHealthCheckHandler.forceCheckAllMSAs();
    verify(matchingServiceHealthChecker, times(1)).performHealthCheck(any(MatchingServiceConfigEntityDataDto.class));
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.Test)

Example 17 with MatchingServiceConfigEntityDataDto

use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.

the class MatchingServiceHealthCheckHandlerTest method handle_shouldReturnSuccessWhenMatchingServiceIsNotHealthy.

@Test
public void handle_shouldReturnSuccessWhenMatchingServiceIsNotHealthy() throws Exception {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto().build();
    when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(asList(matchingServiceConfigEntityDataDto));
    when(matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto)).thenReturn(MatchingServiceHealthCheckResult.unhealthy(MatchingServiceHealthCheckDetailsBuilder.aMatchingServiceHealthCheckDetails().build()));
    AggregatedMatchingServicesHealthCheckResult result = matchingServiceHealthCheckHandler.handle();
    assertThat(result.isHealthy()).isEqualTo(false);
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.Test)

Example 18 with MatchingServiceConfigEntityDataDto

use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.

the class MatchingServiceHealthCheckHandlerTest method handle_shouldExecuteHealthCheckForMatchingServiceWithHealthCheckDisabledWhenForced.

@Test
public void handle_shouldExecuteHealthCheckForMatchingServiceWithHealthCheckDisabledWhenForced() {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withHealthCheckDisabled().build();
    when(matchingServiceConfigProxy.getMatchingServices()).thenReturn(asList(matchingServiceConfigEntityDataDto));
    matchingServiceHealthCheckHandler.forceCheckAllMSAs();
    verify(matchingServiceHealthChecker, times(1)).performHealthCheck(any(MatchingServiceConfigEntityDataDto.class));
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.Test)

Example 19 with MatchingServiceConfigEntityDataDto

use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.

the class MatchingServiceHealthCheckerTest method handle_shouldReturnFailureWithMessageForMatchingServiceThatCannotBeGeneratedBySamlEngine.

@Test
public void handle_shouldReturnFailureWithMessageForMatchingServiceThatCannotBeGeneratedBySamlEngine() throws Exception {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
    when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenThrow(ApplicationException.createAuditedException(ExceptionType.INVALID_INPUT, UUID.randomUUID()));
    MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
    assertThat(result.isHealthy()).isEqualTo(false);
    assertThat(result.getDetails().getDetails()).isEqualTo("Saml-engine was unable to generate saml to send to MSA: uk.gov.ida.exceptions.ApplicationException: Exception of type [INVALID_INPUT] ");
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.Test)

Example 20 with MatchingServiceConfigEntityDataDto

use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto in project verify-hub by alphagov.

the class MatchingServiceHealthCheckerTest method handle_shouldReturnResultWhenVersionReturnedByMsaIsNotSupported.

@Test
public void handle_shouldReturnResultWhenVersionReturnedByMsaIsNotSupported() {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
    prepareForHealthyResponse(matchingServiceConfigEntityDataDto, Optional.of(UNSUPPORTED_MSA_VERSION_NUMBER));
    MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
    assertThat(result.getDetails().isVersionSupported()).isFalse();
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.Test)

Aggregations

MatchingServiceConfigEntityDataDto (uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto)31 Test (org.junit.Test)27 MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto (uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto)27 SamlMessageDto (uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto)5 MatchingServiceHealthCheckResponseDto (uk.gov.ida.hub.samlsoapproxy.domain.MatchingServiceHealthCheckResponseDto)5 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 AttributeQuery (org.opensaml.saml.saml2.core.AttributeQuery)1 ApplicationException (uk.gov.ida.exceptions.ApplicationException)1 MatchingServiceConfigProxy (uk.gov.ida.hub.samlsoapproxy.proxy.MatchingServiceConfigProxy)1 SamlValidationSpecificationFailure (uk.gov.ida.saml.core.validation.SamlValidationSpecificationFailure)1