Search in sources :

Example 51 with MatchingServiceConfigEntityDataDto

use of uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto 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");
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) SamlMessageDto(uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto) MatchingServiceHealthCheckResponseDto(uk.gov.ida.hub.samlsoapproxy.domain.MatchingServiceHealthCheckResponseDto) Test(org.junit.jupiter.api.Test)

Example 52 with MatchingServiceConfigEntityDataDto

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

the class MatchingServiceHealthCheckerTest method shouldReturnVersionIfSameOneIsPresentInResponseIDAndHeaderWithMessageForHealthyMatchingService.

@Test
public void shouldReturnVersionIfSameOneIsPresentInResponseIDAndHeaderWithMessageForHealthyMatchingService() {
    final String versionNumber = "180";
    final Optional<String> headerVersion = Optional.ofNullable(versionNumber);
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
    prepareForHealthyResponse(matchingServiceConfigEntityDataDto);
    mockHealthcheckResponseId("healthcheck-response-id-uuid-version-" + versionNumber);
    MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
    assertThat(result.getDetails().getVersionNumber()).isEqualTo(versionNumber);
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.jupiter.api.Test)

Example 53 with MatchingServiceConfigEntityDataDto

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

the class MatchingServiceHealthCheckerTest method shouldReturnResultWhenVersionIsNotReturnedByMsa.

@Test
public void shouldReturnResultWhenVersionIsNotReturnedByMsa() {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
    prepareForHealthyResponse(matchingServiceConfigEntityDataDto);
    MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
    assertThat(result.getDetails().getVersionNumber()).isEqualTo(DEFAULT_VERSION_VALUE);
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.jupiter.api.Test)

Example 54 with MatchingServiceConfigEntityDataDto

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

the class MatchingServiceHealthCheckerTest method shouldExecuteHealthCheckForMatchingServiceWithHealthCheckEnabled.

@Test
public void shouldExecuteHealthCheckForMatchingServiceWithHealthCheckEnabled() {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withHealthCheckEnabled().build();
    prepareForHealthyResponse(matchingServiceConfigEntityDataDto);
    matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
    verify(matchingServiceHealthCheckClient, times(1)).sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()));
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto(uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto) Test(org.junit.jupiter.api.Test)

Example 55 with MatchingServiceConfigEntityDataDto

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

the class MatchingServiceHealthCheckerTest method shouldReturnReasonableValuesForVersionEidasEnabledAndUseSha1WhenReasonableRequestIdReceived.

@Test
public void shouldReturnReasonableValuesForVersionEidasEnabledAndUseSha1WhenReasonableRequestIdReceived() {
    MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().build();
    prepareForHealthyResponse(matchingServiceConfigEntityDataDto);
    mockHealthcheckResponseId("healthcheck-response-id-version-1234-eidasenabled-true-shouldsignwithsha1-false");
    MatchingServiceHealthCheckResult result = matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
    assertThat(result.getDetails().getVersionNumber()).isEqualTo("1234");
    assertThat(result.getDetails().getEidasEnabled()).isEqualTo("true");
    assertThat(result.getDetails().getShouldSignWithSha1()).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.jupiter.api.Test)

Aggregations

MatchingServiceConfigEntityDataDto (uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceConfigEntityDataDto)58 MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto (uk.gov.ida.hub.samlsoapproxy.builders.MatchingServiceConfigEntityDataDtoBuilder.aMatchingServiceConfigEntityDataDto)51 Test (org.junit.jupiter.api.Test)33 Test (org.junit.Test)18 SamlMessageDto (uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto)9 MatchingServiceHealthCheckResponseDto (uk.gov.ida.hub.samlsoapproxy.domain.MatchingServiceHealthCheckResponseDto)8 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