Search in sources :

Example 11 with RequestAndResponseFilter

use of com.nike.riposte.server.http.filter.RequestAndResponseFilter in project riposte by Nike-Inc.

the class HttpChannelInitializerTest method constructor_handles_empty_before_security_request_handlers.

@Test
public void constructor_handles_empty_before_security_request_handlers() {
    // given
    RequestAndResponseFilter afterSecurityRequestFilter = mock(RequestAndResponseFilter.class);
    doReturn(false).when(afterSecurityRequestFilter).shouldExecuteBeforeSecurityValidation();
    List<RequestAndResponseFilter> reqResFilters = Arrays.asList(afterSecurityRequestFilter);
    // when
    HttpChannelInitializer hci = new HttpChannelInitializer(null, 42, Arrays.asList(getMockEndpoint("/some/path")), reqResFilters, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class), null, null, mock(ResponseSender.class), null, 4242L, null, null, null, 121, 42, 321, 100, false, null);
    // then
    RequestFilterHandler beforeSecReqFH = extractField(hci, "afterSecurityRequestFilterHandler");
    assertThat(extractField(beforeSecReqFH, "filters"), is(Collections.singletonList(afterSecurityRequestFilter)));
    assertThat(extractField(hci, "beforeSecurityRequestFilterHandler"), nullValue());
    ResponseFilterHandler responseFilterHandler = extractField(hci, "cachedResponseFilterHandler");
    assertThat(extractField(responseFilterHandler, "filtersInResponseProcessingOrder"), is(reqResFilters));
}
Also used : RiposteUnhandledErrorHandler(com.nike.riposte.server.error.handler.RiposteUnhandledErrorHandler) RequestFilterHandler(com.nike.riposte.server.handler.RequestFilterHandler) RequestAndResponseFilter(com.nike.riposte.server.http.filter.RequestAndResponseFilter) ResponseFilterHandler(com.nike.riposte.server.handler.ResponseFilterHandler) RiposteErrorHandler(com.nike.riposte.server.error.handler.RiposteErrorHandler) ResponseSender(com.nike.riposte.server.http.ResponseSender) Test(org.junit.Test)

Example 12 with RequestAndResponseFilter

use of com.nike.riposte.server.http.filter.RequestAndResponseFilter in project riposte by Nike-Inc.

the class HttpChannelInitializerTest method createRequestAndResponseFilterMock.

private List<RequestAndResponseFilter> createRequestAndResponseFilterMock() {
    RequestAndResponseFilter beforeSecurityRequestFilter = mock(RequestAndResponseFilter.class);
    doReturn(true).when(beforeSecurityRequestFilter).shouldExecuteBeforeSecurityValidation();
    return Arrays.asList(beforeSecurityRequestFilter);
}
Also used : RequestAndResponseFilter(com.nike.riposte.server.http.filter.RequestAndResponseFilter)

Aggregations

RequestAndResponseFilter (com.nike.riposte.server.http.filter.RequestAndResponseFilter)12 Test (org.junit.Test)9 RequestFilterHandler (com.nike.riposte.server.handler.RequestFilterHandler)5 ResponseFilterHandler (com.nike.riposte.server.handler.ResponseFilterHandler)4 PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)4 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)4 RiposteErrorHandler (com.nike.riposte.server.error.handler.RiposteErrorHandler)3 RiposteUnhandledErrorHandler (com.nike.riposte.server.error.handler.RiposteUnhandledErrorHandler)3 RequestInfo (com.nike.riposte.server.http.RequestInfo)3 ResponseSender (com.nike.riposte.server.http.ResponseSender)3 Pair (com.nike.internal.util.Pair)2 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)2 RequestValidator (com.nike.riposte.server.error.validation.RequestValidator)2 RequestContentDeserializerHandler (com.nike.riposte.server.handler.RequestContentDeserializerHandler)2 RequestInfoSetterHandler (com.nike.riposte.server.handler.RequestInfoSetterHandler)2 RoutingHandler (com.nike.riposte.server.handler.RoutingHandler)2 SecurityValidationHandler (com.nike.riposte.server.handler.SecurityValidationHandler)2 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)2 BiFunction (java.util.function.BiFunction)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1