Search in sources :

Example 41 with SessionId

use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.

the class SamlProxyDuplicateRequestExceptionMapperTest method shouldCreateAuditedErrorResponseForDuplicateRequestIdError.

@Test
public void shouldCreateAuditedErrorResponseForDuplicateRequestIdError() {
    SamlDuplicateRequestIdException exception = new SamlDuplicateRequestIdException("error", new RuntimeException(), Level.DEBUG);
    SessionId sessionId = SessionId.createNewSessionId();
    when(httpServletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn(sessionId.getSessionId());
    Response response = exceptionMapper.handleException(exception);
    ErrorStatusDto responseEntity = (ErrorStatusDto) response.getEntity();
    assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
    assertThat(responseEntity.isAudited()).isTrue();
    assertThat(responseEntity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID);
    verify(eventSinkMessageSender).audit(eq(exception), any(UUID.class), eq(sessionId));
}
Also used : Response(javax.ws.rs.core.Response) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID) SamlDuplicateRequestIdException(uk.gov.ida.saml.hub.exception.SamlDuplicateRequestIdException) SessionId(uk.gov.ida.common.SessionId) Test(org.junit.jupiter.api.Test)

Aggregations

SessionId (uk.gov.ida.common.SessionId)41 Test (org.junit.jupiter.api.Test)31 URI (java.net.URI)17 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)15 SamlValidationResponse (uk.gov.ida.saml.core.validation.SamlValidationResponse)15 Response (javax.ws.rs.core.Response)13 Response (org.opensaml.saml.saml2.core.Response)12 Element (org.w3c.dom.Element)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.samlproxy.contracts.AuthnResponseFromHubContainerDto)6 SamlRequestDto (uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto)5 ResponseActionDto (uk.gov.ida.hub.samlproxy.domain.ResponseActionDto)5 OutboundResponseFromHub (uk.gov.ida.saml.core.domain.OutboundResponseFromHub)5 HubTransformersFactory (uk.gov.ida.saml.hub.api.HubTransformersFactory)4 Timed (com.codahale.metrics.annotation.Timed)3 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Produces (javax.ws.rs.Produces)3 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)3 SamlMessage (uk.gov.ida.hub.samlproxy.controllogic.SamlMessageSenderHandler.SamlMessage)3