@Test
    void verifyDynamicNonceAlreadyGenerated() {
        val servletContext = new MockServletContext();
        val specificFilterConfig = new MockFilterConfig(servletContext);
        specificFilterConfig.addInitParameter(ResponseHeadersEnforcementFilter.INIT_PARAM_CONTENT_SECURITY_POLICY, "script-src '@nonce@';");
        filter.init(specificFilterConfig);

        val servletRequest = new MockHttpServletRequest();
        servletRequest.setSecure(true);
        val alreadyGeneratedNonce = "123456";
        servletRequest.setAttribute(ResponseHeadersEnforcementFilter.CSP_GENERATED_NONCE, alreadyGeneratedNonce);
        val servletResponse = new MockHttpServletResponse();
        filter.doFilter(servletRequest, servletResponse, new MockFilterChain());
        filter.destroy();

        val generatedNonce = servletRequest.getAttribute(ResponseHeadersEnforcementFilter.CSP_GENERATED_NONCE);
        assertEquals(alreadyGeneratedNonce, generatedNonce);
        val contentSecurityPolicy = servletResponse.getHeaderValue("Content-Security-Policy");
        assertEquals("script-src '" + alreadyGeneratedNonce + "';", contentSecurityPolicy);
    }
This is {@link ResponseHeadersEnforcementFilterTests}.

@author Misagh Moayyed
@since 6.2.0
core/cas-server-core-web-api/src/test/java/org/apereo/cas/web/support/filters/ResponseHeadersEnforcementFilterTests.java