From 53c6747712dd87646d146d081b96c469f4d5c362 Mon Sep 17 00:00:00 2001 From: Ziqin Wang Date: Sat, 17 Oct 2026 15:22:01 +0800 Subject: [PATCH] Replace Matcher Explicitly in Replace-CSP Test for Reactive Stack The current headersWhenContentSecurityPolicyConfiguredTwiceThenSecondCallReplacesFirst test relies on the fact that the exchangeMatcher is reset to ServerWebExchangeMatchers.anyExchange() when headers.contentSecurityPolicy(...) is called the second time, which makes it incompatible with gh-19842. This commit aligns the reactive test with HeadersConfigurerTests.ContentSecurityPolicyConfiguredTwiceConfig in the servlet stack to address the aforementioned problem. Signed-off-by: Ziqin Wang --- .../security/config/web/server/HeaderSpecTests.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java index ed964fcf479..73efc505964 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java @@ -544,6 +544,7 @@ public void headersWhenContentSecurityPolicyConfiguredTwiceThenSecondCallReplace .exchangeMatchers("/foo/**") .policyDirectives("script-src 'self'")) .contentSecurityPolicy((csp) -> csp + .exchangeMatchers("/bar/**") .policyDirectives(policyDirectives))); // @formatter:on WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.http.build()).build(); @@ -552,6 +553,10 @@ public void headersWhenContentSecurityPolicyConfiguredTwiceThenSecondCallReplace .uri("https://example.com/bar") .exchange() .expectHeader().valueEquals(headerName, policyDirectives); + client.get() + .uri("https://example.com/foo") + .exchange() + .expectHeader().doesNotExist(headerName); // @formatter:on }