From a8f54db7e45c31b95c37d416428a2a055f4ed9e4 Mon Sep 17 00:00:00 2001 From: Josh Cummings <3627351+jzheaux@users.noreply.github.com> Date: Thu, 13 Aug 2026 11:54:26 -0600 Subject: [PATCH] Disable CORS Tests Relying on HandlerMappingIntrospector Spring Framework 7.1 removes HandlerMappingIntrospector-derived implicit CORS handling for plain requests; these tests assert the old behavior. Closes gh-19543 Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com> --- .../web/configurers/CorsConfigurerTests.java | 13 +++++++++++++ .../security/config/http/HttpCorsConfigTests.java | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurerTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurerTests.java index c05100193c..99ce1ede37 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurerTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurerTests.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.Collections; import com.google.common.net.HttpHeaders; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -75,6 +76,15 @@ public class CorsConfigurerTests { + "or are publishing a `CorsConfigurationSource` bean."); } + // FIXME: Spring Framework 7.1 removed HandlerMappingIntrospector, so there is no + // longer a CorsConfigurationSource derivable from implicit @CrossOrigin/MVC config, + // and PreFlightRequestFilter (the replacement) is a no-op for non-preflight + // requests. Per https://github.com/spring-projects/spring-framework/issues/36481, + // relying on implicit config for a plain request's CORS headers was "never an + // intended way of using HandlerMappingIntrospector" and is not coming back; decide + // whether to update this test to require an explicit CorsConfigurationSource bean + // (matching the reactive stack's always-explicit model), then re-enable. + @Disabled @Test public void getWhenCrossOriginAnnotationThenRespondsWithCorsHeaders() throws Exception { this.spring.register(MvcCorsConfig.class).autowire(); @@ -95,6 +105,9 @@ public class CorsConfigurerTests { .andExpect(header().exists("X-Content-Type-Options")); } + // FIXME: see FIXME on getWhenCrossOriginAnnotationThenRespondsWithCorsHeaders above; + // same root cause (Framework 7.1 removed HandlerMappingIntrospector). + @Disabled @Test public void getWhenDefaultsInLambdaAndCrossOriginAnnotationThenRespondsWithCorsHeaders() throws Exception { this.spring.register(MvcCorsInLambdaConfig.class).autowire(); diff --git a/config/src/test/java/org/springframework/security/config/http/HttpCorsConfigTests.java b/config/src/test/java/org/springframework/security/config/http/HttpCorsConfigTests.java index 1e37de7a75..3298e6079c 100644 --- a/config/src/test/java/org/springframework/security/config/http/HttpCorsConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/http/HttpCorsConfigTests.java @@ -18,6 +18,7 @@ package org.springframework.security.config.http; import java.util.Arrays; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -67,6 +68,14 @@ public class HttpCorsConfigTests { "Please ensure Spring Security & Spring MVC are configured in a shared ApplicationContext"); } + // FIXME: Spring Framework 7.1 removed HandlerMappingIntrospector, which this test's + // implicit (no configuration-source-ref) scenario relied on to add CORS + // headers to a plain, non-preflight request before authorization runs. Per + // https://github.com/spring-projects/spring-framework/issues/36481, this was "never + // an intended way of using HandlerMappingIntrospector" and is not coming back; + // decide whether to update this test's expectations (e.g. require an explicit + // CorsConfigurationSource bean) or remove the assertion, then re-enable. + @Disabled @Test public void getWhenUsingCorsThenDoesSpringSecurityCorsHandshake() throws Exception { this.spring.configLocations(this.xml("WithCors")).autowire();