Fix removal of framework deprecated code
Issue https://github.com/spring-projects/spring-framework/issues/27686
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,6 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
import org.springframework.web.server.handler.DefaultWebFilterChain;
|
||||
import org.springframework.web.server.handler.FilteringWebHandler;
|
||||
|
||||
/**
|
||||
* Used to delegate to a List of {@link SecurityWebFilterChain} instances.
|
||||
@@ -52,7 +51,7 @@ public class WebFilterChainProxy implements WebFilter {
|
||||
.filterWhen((securityWebFilterChain) -> securityWebFilterChain.matches(exchange)).next()
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.flatMap((securityWebFilterChain) -> securityWebFilterChain.getWebFilters().collectList())
|
||||
.map((filters) -> new FilteringWebHandler(chain::filter, filters)).map(DefaultWebFilterChain::new)
|
||||
.map((filters) -> new DefaultWebFilterChain(chain::filter, filters))
|
||||
.flatMap((securedChain) -> securedChain.filter(exchange));
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.security.web.server.authentication;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -95,7 +97,7 @@ public class RedirectServerAuthenticationFailureHandlerTests {
|
||||
|
||||
private WebFilterExchange createExchange() {
|
||||
return new WebFilterExchange(MockServerWebExchange.from(MockServerHttpRequest.get("/").build()),
|
||||
new DefaultWebFilterChain((e) -> Mono.empty()));
|
||||
new DefaultWebFilterChain((e) -> Mono.empty(), Collections.emptyList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.security.web.server.context;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -109,7 +111,8 @@ public class ReactorContextWebFilterTests {
|
||||
given(this.repository.load(any())).willReturn(this.securityContext.mono());
|
||||
String contextKey = "main";
|
||||
WebFilter mainContextWebFilter = (e, c) -> c.filter(e).subscriberContext(Context.of(contextKey, true));
|
||||
WebFilterChain chain = new DefaultWebFilterChain((e) -> Mono.empty(), mainContextWebFilter, this.filter);
|
||||
WebFilterChain chain = new DefaultWebFilterChain((e) -> Mono.empty(),
|
||||
List.of(mainContextWebFilter, this.filter));
|
||||
Mono<Void> filter = chain.filter(MockServerWebExchange.from(this.exchange.build()));
|
||||
StepVerifier.create(filter).expectAccessibleContext().hasKey(contextKey).then().verifyComplete();
|
||||
}
|
||||
|
||||
+6
-3
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.security.web.server.context;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -48,7 +50,8 @@ public class SecurityContextServerWebExchangeWebFilterTests {
|
||||
.filter(this.exchange, new DefaultWebFilterChain((e) -> e.getPrincipal()
|
||||
.doOnSuccess((contextPrincipal) -> assertThat(contextPrincipal).isEqualTo(this.principal))
|
||||
.flatMap((contextPrincipal) -> Mono.subscriberContext())
|
||||
.doOnSuccess((context) -> assertThat(context.<String>get("foo")).isEqualTo("bar")).then()))
|
||||
.doOnSuccess((context) -> assertThat(context.<String>get("foo")).isEqualTo("bar")).then(),
|
||||
Collections.emptyList()))
|
||||
.subscriberContext((context) -> context.put("foo", "bar"))
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(this.principal));
|
||||
StepVerifier.create(result).verifyComplete();
|
||||
@@ -61,7 +64,7 @@ public class SecurityContextServerWebExchangeWebFilterTests {
|
||||
new DefaultWebFilterChain((e) -> e.getPrincipal()
|
||||
.doOnSuccess(
|
||||
(contextPrincipal) -> assertThat(contextPrincipal).isEqualTo(this.principal))
|
||||
.then()))
|
||||
.then(), Collections.emptyList()))
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(this.principal));
|
||||
StepVerifier.create(result).verifyComplete();
|
||||
}
|
||||
@@ -73,7 +76,7 @@ public class SecurityContextServerWebExchangeWebFilterTests {
|
||||
new DefaultWebFilterChain((e) -> e.getPrincipal().defaultIfEmpty(defaultAuthentication)
|
||||
.doOnSuccess(
|
||||
(contextPrincipal) -> assertThat(contextPrincipal).isEqualTo(defaultAuthentication))
|
||||
.then()));
|
||||
.then(), Collections.emptyList()));
|
||||
StepVerifier.create(result).verifyComplete();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user