Search in sources :

Example 1 with DebugRequestWrapper

use of org.springframework.security.web.debug.DebugFilter.DebugRequestWrapper in project spring-security by spring-projects.

the class DebugFilterTests method doFilterProcessesForwardedRequests.

// SEC-1901
@Test
public void doFilterProcessesForwardedRequests() throws Exception {
    setupMocks();
    given(this.request.getAttribute(this.requestAttr)).willReturn(Boolean.TRUE);
    HttpServletRequest request = new DebugRequestWrapper(this.request);
    this.filter.doFilter(request, this.response, this.filterChain);
    verify(this.logger).info(anyString());
    verify(this.fcp).doFilter(request, this.response, this.filterChain);
    verify(this.request, never()).removeAttribute(this.requestAttr);
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DebugRequestWrapper(org.springframework.security.web.debug.DebugFilter.DebugRequestWrapper) Test(org.junit.jupiter.api.Test)

Example 2 with DebugRequestWrapper

use of org.springframework.security.web.debug.DebugFilter.DebugRequestWrapper in project spring-security by spring-projects.

the class DebugFilterTests method doFilterDoesNotWrapWithDebugRequestWrapperAgain.

@Test
public void doFilterDoesNotWrapWithDebugRequestWrapperAgain() throws Exception {
    setupMocks();
    given(this.request.getAttribute(this.requestAttr)).willReturn(Boolean.TRUE);
    HttpServletRequest fireWalledRequest = new HttpServletRequestWrapper(new DebugRequestWrapper(this.request));
    this.filter.doFilter(fireWalledRequest, this.response, this.filterChain);
    verify(this.fcp).doFilter(fireWalledRequest, this.response, this.filterChain);
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DebugRequestWrapper(org.springframework.security.web.debug.DebugFilter.DebugRequestWrapper) HttpServletRequestWrapper(jakarta.servlet.http.HttpServletRequestWrapper) Test(org.junit.jupiter.api.Test)

Aggregations

HttpServletRequest (jakarta.servlet.http.HttpServletRequest)2 Test (org.junit.jupiter.api.Test)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 DebugRequestWrapper (org.springframework.security.web.debug.DebugFilter.DebugRequestWrapper)2 HttpServletRequestWrapper (jakarta.servlet.http.HttpServletRequestWrapper)1