use of uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto in project verify-hub by alphagov.
the class AttributeQueryRequestRunnableTest method run_shouldEvaluateTimeoutBeforeSendingRequest.
@Test
public void run_shouldEvaluateTimeoutBeforeSendingRequest() {
doThrow(new AttributeQueryTimeoutException()).when(timeoutEvaluator).hasAttributeQueryTimedOut(attributeQueryContainerDto);
// This represents the queue being full/slow - so don't make matters worse by doing slow work that's not needed.
attributeQueryRequestRunnable.run();
verify(executeAttributeQueryRequest, never()).execute(any(SessionId.class), any(AttributeQueryContainerDto.class));
verify(eventSinkProxy, times(1)).logHubEvent(isA(EventSinkHubEvent.class));
verify(eventEmitter, times(1)).record(isA(EventSinkHubEvent.class));
}
use of uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto in project verify-hub by alphagov.
the class MatchingServiceRequestSenderTest method sendHubMatchingServiceRequest_shouldAcceptAValidRequest.
@Test
public void sendHubMatchingServiceRequest_shouldAcceptAValidRequest() throws Exception {
Credential signingCredential = hubSigningCredential;
AttributeQueryContainerDto attributeQueryContainerDto = AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto(AttributeQueryBuilder.anAttributeQuery().withSignature(SignatureBuilder.aSignature().withSigningCredential(signingCredential).build()).withIssuer(IssuerBuilder.anIssuer().withIssuerId(HUB_ENTITY_ID).build()).build()).withIssuerId(HUB_ENTITY_ID).withMatchingServiceUri(msaStubRule.getAttributeQueryRequestUri()).build();
SessionId sessionId = SessionId.createNewSessionId();
final URI uri = UriBuilder.fromUri(samlSoapProxyAppRule.getUri(Urls.SamlSoapProxyUrls.MATCHING_SERVICE_REQUEST_SENDER_RESOURCE)).queryParam(Urls.SharedUrls.SESSION_ID_PARAM, sessionId).build();
String path = UriBuilder.fromPath(ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId).getPath();
policyStubRule.register(path, 200);
Response response = post(attributeQueryContainerDto, uri);
assertThat(response.getStatus()).isEqualTo(Response.Status.ACCEPTED.getStatusCode());
andPolicyShouldReceiveASuccess(sessionId);
}
use of uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto in project verify-hub by alphagov.
the class MatchingServiceRequestSenderTest method sendHubMatchingServiceRequest_shouldErrorIfRequestIsBad_wrongIssuer.
// When a bad request is made, it is nevertheless accepted - these bad requests are unit tested in
// AttributeQueryRequestRunnableTest
// So, this test is probably of dubious value but probably worth keeping given we have already spun up the
// SamlSoapProxyAppRule
@Test
public void sendHubMatchingServiceRequest_shouldErrorIfRequestIsBad_wrongIssuer() {
AttributeQueryContainerDto attributeQueryContainerDto = AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto(AttributeQueryBuilder.anAttributeQuery().withIssuer(IssuerBuilder.anIssuer().withIssuerId(HUB_ENTITY_ID).build()).build()).withIssuerId(TEST_RP).withMatchingServiceUri(msaStubRule.getAttributeQueryRequestUri()).build();
SessionId sessionId = SessionId.createNewSessionId();
final URI uri = UriBuilder.fromUri(samlSoapProxyAppRule.getUri(Urls.SamlSoapProxyUrls.MATCHING_SERVICE_REQUEST_SENDER_RESOURCE)).queryParam(Urls.SharedUrls.SESSION_ID_PARAM, sessionId).build();
Response response = post(attributeQueryContainerDto, uri);
assertThat(response.getStatus()).isEqualTo(Response.Status.ACCEPTED.getStatusCode());
andPolicyShouldReceiveAFailure(sessionId);
}
Aggregations