Search in sources :

Example 26 with ApplicationException

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

the class SamlProxyApplicationExceptionMapperTest method toResponse_shouldAuditException.

@Test
public void toResponse_shouldAuditException() {
    URI exceptionUri = URI.create("/exception-uri");
    ApplicationException exception = createUnauditedException(exceptionType, errorId, exceptionUri);
    mapper.toResponse(exception);
    verify(exceptionAuditor).auditException(exception, Optional.of(sessionId));
}
Also used : ApplicationException(uk.gov.ida.exceptions.ApplicationException) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 27 with ApplicationException

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

the class SamlProxyApplicationExceptionMapperTest method toResponse_shouldReturnAuditedErrorResponse.

@Test
public void toResponse_shouldReturnAuditedErrorResponse() {
    ApplicationException exception = createAuditedException(exceptionType, errorId);
    final Response response = mapper.toResponse(exception);
    ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
    assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
    assertThat(responseEntity.isAudited()).isTrue();
}
Also used : Response(javax.ws.rs.core.Response) ApplicationException(uk.gov.ida.exceptions.ApplicationException) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) 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