Disable Lowercase HTTP Method Firewall Test
Spring Framework's HttpMethod#valueOf now normalizes casing, so StrictServerWebExchangeFirewall no longer detects a non-canonical-case HTTP method as distinct from its canonical form. Closes gh-19541 Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
This commit is contained in:
@@ -4,3 +4,7 @@
|
||||
== Authentication
|
||||
|
||||
* https://github.com/spring-projects/spring-security/issues/17655[gh-17655] - Make One-Time Token xref:servlet/authentication/onetimetoken.adoc#validating-account-status[account status checks opt-in]
|
||||
|
||||
== Web
|
||||
|
||||
* Since Spring Framework's `HttpMethod#valueOf` now normalizes casing, `StrictServerWebExchangeFirewall` no longer detects a non-canonical-case HTTP method (for example, `get` instead of `GET`) as a distinct value; such requests are processed as the canonical method instead of being rejected. Applications with a customized `ServerExchangeRejectedHandler` should be aware it is no longer invoked for this case.
|
||||
|
||||
+7
-1
@@ -20,6 +20,7 @@ import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -127,8 +128,13 @@ class StrictServerWebExchangeFirewallTests {
|
||||
assertThatExceptionOfType(ServerExchangeRejectedException.class).isThrownBy(() -> getFirewalledExchange());
|
||||
}
|
||||
|
||||
// FIXME: since Spring Framework's HttpMethod#valueOf now normalizes casing,
|
||||
// HttpMethod.valueOf("get") is HttpMethod.GET, so the request is no longer
|
||||
// distinguishable as non-canonical case by the time it reaches the firewall.
|
||||
// The request is still processed as an ordinary GET (not "served" as lowercase),
|
||||
// but a customized ServerExchangeRejectedHandler will no longer be invoked for it.
|
||||
@Test
|
||||
// HTTP methods are case sensitive
|
||||
@Disabled("HTTP method case is normalized by Spring Framework before reaching the firewall")
|
||||
void getFirewalledExchangeWhenLowercaseGetThenThrowsServerExchangeRejectedException() {
|
||||
this.request = MockServerHttpRequest.method(HttpMethod.valueOf("get"), "/");
|
||||
assertThatExceptionOfType(ServerExchangeRejectedException.class).isThrownBy(() -> getFirewalledExchange());
|
||||
|
||||
Reference in New Issue
Block a user