Search in sources :

Example 1 with RecordedRequest

use of httpstub.RecordedRequest in project verify-hub by alphagov.

the class SamlEngineStubRule method getSamlAuthnResponseTranslatorDto.

public SamlAuthnResponseTranslatorDto getSamlAuthnResponseTranslatorDto(ObjectMapper objectMapper) throws java.io.IOException {
    List<RecordedRequest> recordedRequest = getRecordedRequest();
    RecordedRequest recordedTranslateRequest = recordedRequest.stream().filter(request -> {
        return request.getPath().equals(Urls.SamlEngineUrls.TRANSLATE_IDP_AUTHN_RESPONSE_RESOURCE);
    }).findFirst().get();
    return objectMapper.readValue(recordedTranslateRequest.getEntity(), SamlAuthnResponseTranslatorDto.class);
}
Also used : RecordedRequest(httpstub.RecordedRequest)

Example 2 with RecordedRequest

use of httpstub.RecordedRequest in project verify-hub by alphagov.

the class EidasSessionResourceContractTest method assertThatAQRReceivedBySamlSoapProxyHasSameDataAsSamlEngineSent.

private void assertThatAQRReceivedBySamlSoapProxyHasSameDataAsSamlEngineSent() throws Exception {
    RecordedRequest request = samlSoapProxyProxyStub.getLastRequest();
    assertThat(samlSoapProxyProxyStub.getCountOfRequests()).isEqualTo(1);
    assertThat(request.getPath()).isEqualTo(Urls.SamlSoapProxyUrls.MATCHING_SERVICE_REQUEST_SENDER_RESOURCE);
    String unzipped = IOUtils.toString(new GZIPInputStream(new ByteArrayInputStream(request.getEntityBytes())));
    AttributeQueryRequest aqr = policy.getObjectMapper().readValue(unzipped, AttributeQueryRequest.class);
    assertThat(aqr.getSamlRequest()).isEqualTo(SAML_ATTRIBUTE_QUERY);
    assertThat(aqr.getMatchingServiceUri().toASCIIString()).isEqualTo(MATCHING_SERVICE_URI);
    assertThat(aqr.getId()).isEqualTo(ID);
    assertThat(aqr.getIssuer()).isEqualTo(EIDAS_HUB_ENTITY_ID);
    assertThat(aqr.isOnboarding()).isTrue();
}
Also used : RecordedRequest(httpstub.RecordedRequest) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) AttributeQueryRequest(uk.gov.ida.hub.policy.proxy.AttributeQueryRequest)

Example 3 with RecordedRequest

use of httpstub.RecordedRequest in project verify-hub by alphagov.

the class MatchingServiceRequestSenderTest method andPolicyShouldReceiveTheResult.

private void andPolicyShouldReceiveTheResult(SessionId sessionId, String resultPath) {
    await().atMost(5, TimeUnit.SECONDS).until(() -> !policyStubRule.getRecordedRequest().isEmpty());
    RecordedRequest recordedRequest = policyStubRule.getLastRequest();
    String path = UriBuilder.fromPath(resultPath).build(sessionId).getPath();
    ExpectedRequest expectedRequest = ExpectedRequestBuilder.expectRequest().withPath(path).build();
    assertThat(expectedRequest.applies(recordedRequest)).describedAs("The response was not sent to the correct path: expected '%s', but got '%s'", path, recordedRequest.getPath()).isTrue();
}
Also used : RecordedRequest(httpstub.RecordedRequest) ExpectedRequest(httpstub.ExpectedRequest)

Aggregations

RecordedRequest (httpstub.RecordedRequest)3 ExpectedRequest (httpstub.ExpectedRequest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 AttributeQueryRequest (uk.gov.ida.hub.policy.proxy.AttributeQueryRequest)1