Search in sources :

Example 1 with MatchingServiceHealthCheckerResponseDto

use of uk.gov.ida.hub.samlengine.contracts.MatchingServiceHealthCheckerResponseDto in project verify-hub by alphagov.

the class MatchingServiceHealthcheckResponseTranslatorService method translate.

public MatchingServiceHealthCheckerResponseDto translate(SamlMessageDto samlMessageDto) {
    Response response = responseUnmarshaller.apply(samlMessageDto.getSamlMessage());
    MdcHelper.addContextToMdc(response);
    final InboundHealthCheckResponseFromMatchingService responseFromMatchingService = samlResponseToInboundHealthCheckResponseFromMatchingServiceTransformer.transform(response);
    final MatchingServiceHealthCheckerResponseDto matchingServiceHealthCheckerResponseDto = new MatchingServiceHealthCheckerResponseDto(responseFromMatchingService.getStatus(), responseFromMatchingService.getInResponseTo(), responseFromMatchingService.getIssuer(), responseFromMatchingService.getId());
    return matchingServiceHealthCheckerResponseDto;
}
Also used : Response(org.opensaml.saml.saml2.core.Response) MatchingServiceHealthCheckerResponseDto(uk.gov.ida.hub.samlengine.contracts.MatchingServiceHealthCheckerResponseDto) InboundHealthCheckResponseFromMatchingService(uk.gov.ida.saml.hub.domain.InboundHealthCheckResponseFromMatchingService)

Example 2 with MatchingServiceHealthCheckerResponseDto

use of uk.gov.ida.hub.samlengine.contracts.MatchingServiceHealthCheckerResponseDto in project verify-hub by alphagov.

the class MatchingServiceHealthcheckResponseTranslatorResourceTest method should_translateHealthcheckAttributeQueryResponse.

@Test
public void should_translateHealthcheckAttributeQueryResponse() throws Exception {
    final String msaStatusCode = SamlStatusCode.HEALTHY;
    final Status status = aStatus().withStatusCode(aStatusCode().withSubStatusCode(aStatusCode().withValue(msaStatusCode).build()).withValue(StatusCode.SUCCESS).build()).build();
    final String requestId = "requestId";
    final String saml = aValidMatchResponseFromMatchingService(requestId, status, DateTime.now().plusHours(1));
    Response response = postResponseForTranslation(new SamlMessageDto(Base64.encodeAsString(saml)));
    MatchingServiceHealthCheckerResponseDto entity = response.readEntity(MatchingServiceHealthCheckerResponseDto.class);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    assertThat(entity.getStatus()).isEqualTo(MatchingServiceIdaStatus.Healthy);
    assertThat(entity.getInResponseTo()).isEqualTo(requestId);
    assertThat(entity.getIssuer()).isEqualTo(TEST_RP_MS);
}
Also used : Status(org.opensaml.saml.saml2.core.Status) MatchingServiceIdaStatus(uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus) StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) Response(javax.ws.rs.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlMessageDto(uk.gov.ida.hub.samlengine.domain.SamlMessageDto) MatchingServiceHealthCheckerResponseDto(uk.gov.ida.hub.samlengine.contracts.MatchingServiceHealthCheckerResponseDto) Test(org.junit.Test)

Aggregations

MatchingServiceHealthCheckerResponseDto (uk.gov.ida.hub.samlengine.contracts.MatchingServiceHealthCheckerResponseDto)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 Response (org.opensaml.saml.saml2.core.Response)1 Status (org.opensaml.saml.saml2.core.Status)1 SamlMessageDto (uk.gov.ida.hub.samlengine.domain.SamlMessageDto)1 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)1 StatusBuilder.aStatus (uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus)1 InboundHealthCheckResponseFromMatchingService (uk.gov.ida.saml.hub.domain.InboundHealthCheckResponseFromMatchingService)1 MatchingServiceIdaStatus (uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus)1