Search in sources :

Example 6 with ApplicationException

use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.

the class ExceptionAuditorTest method shouldNotAuditUnauditedExceptionIfItDoesNotRequireAuditing.

@Test
public void shouldNotAuditUnauditedExceptionIfItDoesNotRequireAuditing() {
    ApplicationException exception = createUnauditedExceptionThatShouldNotBeAudited();
    exceptionAuditor.auditException(exception, Optional.of(SESSION_ID));
    verify(eventSinkMessageSender, never()).audit(any(Exception.class), any(UUID.class), any(SessionId.class), any(EventDetails.class));
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) UUID(java.util.UUID) SessionId(uk.gov.ida.common.SessionId) ApplicationException.createAuditedException(uk.gov.ida.exceptions.ApplicationException.createAuditedException) ApplicationException(uk.gov.ida.exceptions.ApplicationException) ApplicationException.createUnauditedException(uk.gov.ida.exceptions.ApplicationException.createUnauditedException) EventDetails(uk.gov.ida.hub.shared.eventsink.EventDetails) Test(org.junit.jupiter.api.Test)

Example 7 with ApplicationException

use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.

the class ExceptionAuditorTest method shouldNotAuditAlreadyAuditedException.

@Test
public void shouldNotAuditAlreadyAuditedException() {
    final UUID errorId = UUID.randomUUID();
    ApplicationException exception = createAuditedException(ExceptionType.DUPLICATE_SESSION, errorId);
    exceptionAuditor.auditException(exception, Optional.of(SESSION_ID));
    verify(eventSinkMessageSender, never()).audit(any(Exception.class), any(UUID.class), any(SessionId.class), any(EventDetails.class));
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) UUID(java.util.UUID) SessionId(uk.gov.ida.common.SessionId) ApplicationException.createAuditedException(uk.gov.ida.exceptions.ApplicationException.createAuditedException) ApplicationException(uk.gov.ida.exceptions.ApplicationException) ApplicationException.createUnauditedException(uk.gov.ida.exceptions.ApplicationException.createUnauditedException) EventDetails(uk.gov.ida.hub.shared.eventsink.EventDetails) Test(org.junit.jupiter.api.Test)

Example 8 with ApplicationException

use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.

the class SamlProxyApplicationExceptionMapperTest method shouldLogExceptionAtCorrectLevel.

@Test
public void shouldLogExceptionAtCorrectLevel() {
    ApplicationException exception = createAuditedException(exceptionType, errorId);
    mapper.toResponse(exception);
    verify(levelLogger).log(eq(exception.getExceptionType().getLevel()), eq(exception), any(UUID.class));
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 9 with ApplicationException

use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.

the class HealthCheckEventLoggerTest method shouldNotLogToEventSinkIfTheExceptionIsAudited.

@Test
public void shouldNotLogToEventSinkIfTheExceptionIsAudited() {
    ApplicationException unauditedException = ApplicationException.createAuditedException(ExceptionType.INVALID_SAML, UUID.randomUUID());
    eventLogger.logException(unauditedException, "test error message");
    verify(eventSinkProxy, times(0)).logHubEvent(any());
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) Test(org.junit.jupiter.api.Test)

Example 10 with ApplicationException

use of uk.gov.ida.exceptions.ApplicationException in project verify-hub by alphagov.

the class HealthCheckEventLoggerTest method shouldNotLogToEventSinkIfTheExceptionIsUnauditedButShouldNotBeaudited.

@Test
public void shouldNotLogToEventSinkIfTheExceptionIsUnauditedButShouldNotBeaudited() {
    ApplicationException unauditedException = ApplicationException.createUnauditedException(ExceptionType.NETWORK_ERROR, UUID.randomUUID());
    eventLogger.logException(unauditedException, "test error message");
    verify(eventSinkProxy, times(0)).logHubEvent(any());
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationException (uk.gov.ida.exceptions.ApplicationException)27 Test (org.junit.jupiter.api.Test)20 UUID (java.util.UUID)8 Response (javax.ws.rs.core.Response)7 ErrorStatusDto (uk.gov.ida.common.ErrorStatusDto)6 URI (java.net.URI)4 SamlMessageDto (uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto)4 EventDetails (uk.gov.ida.hub.shared.eventsink.EventDetails)4 MatchingServiceHealthCheckResponseDto (uk.gov.ida.hub.samlsoapproxy.domain.MatchingServiceHealthCheckResponseDto)3 SessionId (uk.gov.ida.common.SessionId)2 ApplicationException.createAuditedException (uk.gov.ida.exceptions.ApplicationException.createAuditedException)2 ApplicationException.createUnauditedException (uk.gov.ida.exceptions.ApplicationException.createUnauditedException)2 MatchingServiceHealthCheckerResponseDto (uk.gov.ida.hub.samlsoapproxy.contract.MatchingServiceHealthCheckerResponseDto)2 Timer (com.codahale.metrics.Timer)1 Timed (com.codahale.metrics.annotation.Timed)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 DateTime (org.joda.time.DateTime)1 Element (org.w3c.dom.Element)1 SAXException (org.xml.sax.SAXException)1