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);
}
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();
}
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();
}
Aggregations