use of uk.gov.ida.common.SessionId 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);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldThrowCertChainValidationExceptionOnResponse.
@Test
public void run_shouldThrowCertChainValidationExceptionOnResponse() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
final BasicX509Credential x509Credential = new BasicX509Credential(new X509CertificateFactory().createCertificate(UNCHAINED_PUBLIC_CERT), new PrivateKeyFactory().createPrivateKey(Base64.decode(UNCHAINED_PRIVATE_KEY.getBytes())));
Response response = aResponse().withSigningCredential(x509Credential).withIssuer(anIssuer().withIssuerId("issuer-id").build()).build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingResponseSignatureValidator).validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldCallSamlMessageSignatureValidatorWithResponse.
@Test
public void run_shouldCallSamlMessageSignatureValidatorWithResponse() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
Response response = aResponse().withIssuer(anIssuer().withIssuerId("issuer-id").build()).build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingResponseSignatureValidator).validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldCallInboundMessageValidatorWithResponse.
@Test
public void run_shouldCallInboundMessageValidatorWithResponse() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
Response response = aResponse().build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingResponseSignatureValidator).validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
Aggregations