@Test
    void verifyFilter() throws Throwable {
        assertNotNull(threadContextMDCServletFilter);

        val request = new MockHttpServletRequest();
        assertNotNull(request.getSession(true));

        request.setRequestURI("/cas/login");
        request.setRemoteAddr("1.2.3.4");
        request.setRemoteUser("casuser");
        request.setServerName("serverName");
        request.setServerPort(1000);
        request.setContextPath("ctxpath");
        request.setContentType("contenttype");
        request.setRemotePort(2000);
        request.setQueryString("queryString");
        request.setMethod("method");
        request.setParameter("p1", "v1");
        request.setParameter("password", "helloworld");
        request.setParameter("confirmedPassword", "123456");
        request.setAttribute("a1", "v1");
        request.addHeader("h1", "v1");
        request.addHeader("cookie", "TGC = 12345; SESSION=12345667");

        val response = new MockHttpServletResponse();
        val filterChain = new MockFilterChain();

        val cookieBuilder = mock(CasCookieBuilder.class);
        val ticketSupport = mock(TicketRegistrySupport.class);
        when(cookieBuilder.retrieveCookieValue(any(HttpServletRequest.class))).thenReturn("TICKET");
        when(ticketSupport.getAuthenticatedPrincipalFrom(anyString())).thenReturn(CoreAuthenticationTestUtils.getPrincipal());
        val filter = threadContextMDCServletFilter.getFilter();
        filter.init(mock(FilterConfig.class));
        filter.doFilter(request, response, filterChain);
        assertEquals(HttpStatus.OK.value(), response.getStatus());

        val mdcElements = MDC.getCopyOfContextMap();
        assertEquals(HttpStatus.OK.value(), response.getStatus());
        assertFalse(mdcElements.containsKey("password"));
        assertFalse(mdcElements.containsKey("confirmedPassword"));
        assertFalse(mdcElements.containsKey("cookie"));
        assertNotNull(request.getAttribute("sessionId"));
        assertNotNull(response.getHeader("X-RequestId"));
        assertNotNull(response.getHeader("X-SessionId"));
    }
This is {@link ThreadContextMDCServletFilterTests}.

@author Misagh Moayyed
@since 5.3.0
core/cas-server-core-logging/src/test/java/org/apereo/cas/logging/web/ThreadContextMDCServletFilterTests.java