1
0
mirror of synced 2026-08-26 20:17:58 +00:00

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>
This commit is contained in:
Josh Cummings
2026-08-13 11:54:26 -06:00
parent 24bfdc1dee
commit a8f54db7e4
2 changed files with 22 additions and 0 deletions
@@ -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();
@@ -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) <cors/> 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();