use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class ProtectiveMonitoringLogFormatterTest method shouldFormatResponseWithNoIssuer.
@Test
public void shouldFormatResponseWithNoIssuer() throws MarshallingException, SignatureException {
Response response = aResponse().withIssuer(null).build();
String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(response, Direction.INBOUND, SignatureStatus.VALID_SIGNATURE);
assertThat(logString).contains("issuerId: ,");
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldLogStatusMessageIfItExists.
@Test
public void run_shouldLogStatusMessageIfItExists() throws MarshallingException, SignatureException {
final Element matchingServiceResponse = mock(Element.class);
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
String message = "Some message";
StatusMessage statusMessage = StatusMessageBuilder.aStatusMessage().withMessage(message).build();
Response response = aResponse().withStatus(StatusBuilder.aStatus().withMessage(statusMessage).build()).build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(protectiveMonitoringLogger).logAttributeQueryResponse(response.getID(), response.getInResponseTo(), response.getIssuer().getValue(), true, response.getStatus().getStatusCode().getValue(), message);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldCallSamlMessageSignatureValidatorWithRequest.
@Test
public void run_shouldCallSamlMessageSignatureValidatorWithRequest() 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(matchingRequestSignatureValidator).validate(attributeQuery, HUB_ROLE);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldUseCorrectSignatureValidators.
@Test
public void run_shouldUseCorrectSignatureValidators() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
final Response response = aResponse().build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingRequestSignatureValidator).validate(attributeQuery, HUB_ROLE);
verify(matchingResponseSignatureValidator).validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldLogProtectiveMonitoringCorrectly.
@Test
public void run_shouldLogProtectiveMonitoringCorrectly() throws Exception {
final Element matchingServiceResponse = mock(Element.class);
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(protectiveMonitoringLogger).logAttributeQuery(attributeQuery.getID(), attributeQueryContainerDto.getMatchingServiceUri().toASCIIString(), attributeQuery.getIssuer().getValue(), true);
verify(protectiveMonitoringLogger).logAttributeQueryResponse(response.getID(), response.getInResponseTo(), response.getIssuer().getValue(), true, response.getStatus().getStatusCode().getValue(), "");
}
Aggregations