use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method shouldLogExceptionsWhenAFailureOccursInGeneratingHealthCheckRequest.
@Test
public void shouldLogExceptionsWhenAFailureOccursInGeneratingHealthCheckRequest() {
ApplicationException unauditedException = ApplicationException.createUnauditedException(ExceptionType.INVALID_SAML, UUID.randomUUID());
when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenThrow(unauditedException);
matchingServiceHealthChecker.performHealthCheck(aMatchingServiceConfigEntityDataDto().build());
verify(eventLogger).logException(unauditedException, "Saml-engine was unable to generate saml to send to MSA: uk.gov.ida.exceptions.ApplicationException: Exception of type [INVALID_SAML] ");
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method shouldLogExceptionsWhenAFailureOccursInTranslatingHealthCheckRequest.
@Test
public void shouldLogExceptionsWhenAFailureOccursInTranslatingHealthCheckRequest() {
String uri = "http://random";
ApplicationException unauditedException = ApplicationException.createUnauditedException(ExceptionType.INVALID_SAML, UUID.randomUUID());
when(samlEngineProxy.generateHealthcheckAttributeQuery(any())).thenReturn(new SamlMessageDto("<saml/>"));
when(samlEngineProxy.translateHealthcheckMatchingServiceResponse(any())).thenThrow(unauditedException);
MatchingServiceConfigEntityDataDto matchingServiceConfigEntityDataDto = aMatchingServiceConfigEntityDataDto().withUri(uri).build();
when(matchingServiceHealthCheckClient.sendHealthCheckRequest(any(), eq(matchingServiceConfigEntityDataDto.getUri()))).thenReturn(new MatchingServiceHealthCheckResponseDto(Optional.of("<saml/>")));
matchingServiceHealthChecker.performHealthCheck(matchingServiceConfigEntityDataDto);
verify(eventLogger).logException(unauditedException, MessageFormat.format("Matching service health check failed for URI {0}", uri));
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class HealthCheckSoapRequestClientTest method makePost_shouldEnsureResponseInputStreamIsClosedWhenResponseCodeIsNot200.
@Test
public void makePost_shouldEnsureResponseInputStreamIsClosedWhenResponseCodeIsNot200() throws URISyntaxException {
when(response.getStatus()).thenReturn(502);
URI matchingServiceUri = new URI("http://heyyeyaaeyaaaeyaeyaa.com/abc1");
try {
healthCheckSoapRequestClient.makeSoapRequestForHealthCheck(null, matchingServiceUri);
fail("Exception should have been thrown");
} catch (ApplicationException e) {
verify(response).close();
}
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class ExceptionAuditorTest method shouldAuditUnauditedException.
@Test
public void shouldAuditUnauditedException() {
DateTime expectedTimestamp = DateTime.now();
DateTimeFreezer.freezeTime(expectedTimestamp);
final UUID errorId = UUID.randomUUID();
ApplicationException exception = createUnauditedException(ExceptionType.DUPLICATE_SESSION, errorId, URI.create("/some-uri"));
exceptionAuditor.auditException(exception, Optional.of(SESSION_ID));
ArgumentCaptor<EventDetails> argumentCaptor = ArgumentCaptor.forClass(EventDetails.class);
verify(eventSinkMessageSender).audit(eq(exception), eq(errorId), eq(SESSION_ID), argumentCaptor.capture());
final EventDetails event = argumentCaptor.getValue();
assertThat(event.getKey()).isEqualTo(downstream_uri);
assertThat(event.getValue()).isEqualTo(exception.getUri().get().toASCIIString());
}
use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.
the class ExceptionAuditorTest method shouldAuditWithNoSessionContextIfSessionIdIsNotPresent.
@Test
public void shouldAuditWithNoSessionContextIfSessionIdIsNotPresent() {
final UUID errorId = UUID.randomUUID();
ApplicationException exception = createUnauditedException(ExceptionType.DUPLICATE_SESSION, errorId, URI.create("/some-uri"));
exceptionAuditor.auditException(exception, Optional.empty());
verify(eventSinkMessageSender).audit(eq(exception), eq(errorId), eq(SessionId.NO_SESSION_CONTEXT_IN_ERROR), any(EventDetails.class));
}
Aggregations