Search in sources :

Example 1 with AttributeQueryContainerDto

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));
}
Also used : AttributeQueryContainerDto(uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto) AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto(uk.gov.ida.hub.samlsoapproxy.builders.AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto) AttributeQueryTimeoutException(uk.gov.ida.hub.samlsoapproxy.exceptions.AttributeQueryTimeoutException) SessionId(uk.gov.ida.common.SessionId) EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent) Test(org.junit.Test)

Example 2 with AttributeQueryContainerDto

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);
}
Also used : RequestAndResponse(httpstub.RequestAndResponse) Response(javax.ws.rs.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) AttributeQueryContainerDto(uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto) Credential(org.opensaml.security.credential.Credential) SessionId(uk.gov.ida.common.SessionId) URI(java.net.URI) Test(org.junit.Test)

Example 3 with AttributeQueryContainerDto

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);
}
Also used : RequestAndResponse(httpstub.RequestAndResponse) Response(javax.ws.rs.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) AttributeQueryContainerDto(uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto) SessionId(uk.gov.ida.common.SessionId) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 SessionId (uk.gov.ida.common.SessionId)3 AttributeQueryContainerDto (uk.gov.ida.hub.samlsoapproxy.domain.AttributeQueryContainerDto)3 RequestAndResponse (httpstub.RequestAndResponse)2 URI (java.net.URI)2 Response (javax.ws.rs.core.Response)2 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)2 Credential (org.opensaml.security.credential.Credential)1 EventSinkHubEvent (uk.gov.ida.eventsink.EventSinkHubEvent)1 AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto (uk.gov.ida.hub.samlsoapproxy.builders.AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto)1 AttributeQueryTimeoutException (uk.gov.ida.hub.samlsoapproxy.exceptions.AttributeQueryTimeoutException)1