use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class SamlProxySamlTransformationErrorExceptionMapperTest method shouldLogToEventSinkWhenExceptionHasContextAndSessionId.
@Test
public void shouldLogToEventSinkWhenExceptionHasContextAndSessionId() throws Exception {
TestSamlTransformationErrorException exception = new TestSamlTransformationErrorException("error", new RuntimeException(), Level.DEBUG);
SessionId sessionId = SessionId.createNewSessionId();
when(httpServletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn(sessionId.getSessionId());
exceptionMapper.handleException(exception);
verify(eventSinkMessageSender).audit(eq(exception), any(UUID.class), eq(sessionId));
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class AttributeQueryRequestRunnableTest method run_shouldNotSendResponse_IfAttributeQueryHasTimedOut_AfterSendingMessage.
@Test
public void run_shouldNotSendResponse_IfAttributeQueryHasTimedOut_AfterSendingMessage() throws Exception {
final Element matchingServiceResponse = XmlUtils.convertToElement("<someResponse/>");
when(executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto)).thenReturn(matchingServiceResponse);
doNothing().doThrow(new AttributeQueryTimeoutException()).when(timeoutEvaluator).hasAttributeQueryTimedOut(attributeQueryContainerDto);
attributeQueryRequestRunnable.run();
verify(executeAttributeQueryRequest).execute(sessionId, attributeQueryContainerDto);
verify(hubMatchingServiceResponseReceiverProxy, never()).notifyHubOfAResponseFromMatchingService(any(SessionId.class), any(String.class));
verify(eventSinkProxy, times(1)).logHubEvent(isA(EventSinkHubEvent.class));
verify(eventEmitter, times(1)).record(isA(EventSinkHubEvent.class));
}
use of uk.gov.ida.common.SessionId 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, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
use of uk.gov.ida.common.SessionId 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 uk.gov.ida.common.SessionId 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