1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Replace removed context-related operators

Closes gh-11194
This commit is contained in:
Marcus Da Coregio
2022-05-10 14:50:19 -03:00
parent b803e845e7
commit 806e05855c
45 changed files with 194 additions and 204 deletions
@@ -432,7 +432,7 @@ public final class SecurityMockServerConfigurers {
if (context != null) {
exchange.getAttributes().remove(ATTRIBUTE_NAME);
return webFilterChain.filter(exchange)
.subscriberContext(ReactiveSecurityContextHolder.withSecurityContext(context.get()));
.contextWrite(ReactiveSecurityContextHolder.withSecurityContext(context.get()));
}
return webFilterChain.filter(exchange);
}
@@ -101,7 +101,7 @@ public class ReactorContextTestExecutionListenerTests {
this.listener.beforeTestMethod(this.testContext);
Mono<Authentication> authentication = Mono.just("any")
.flatMap((s) -> ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication))
.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(expectedAuthentication));
.contextWrite(ReactiveSecurityContextHolder.withAuthentication(expectedAuthentication));
StepVerifier.create(authentication).expectNext(expectedAuthentication).verifyComplete();
}
@@ -115,7 +115,7 @@ public class ReactorContextTestExecutionListenerTests {
this.listener.beforeTestMethod(this.testContext);
Mono<Authentication> authentication = Mono.just("any")
.flatMap((s) -> ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication))
.subscriberContext(ReactiveSecurityContextHolder.clearContext());
.contextWrite(ReactiveSecurityContextHolder.clearContext());
StepVerifier.create(authentication).verifyComplete();
}
@@ -129,7 +129,7 @@ public class ReactorContextTestExecutionListenerTests {
public void afterTestMethodWhenSetupThenReactorContextNull() throws Exception {
beforeTestMethodWhenAuthenticationThenReactorContextHasAuthentication();
this.listener.afterTestMethod(this.testContext);
assertThat(Mono.subscriberContext().block().isEmpty()).isTrue();
assertThat(Mono.deferContextual(Mono::just).block().isEmpty()).isTrue();
}
@Test
@@ -137,7 +137,7 @@ public class ReactorContextTestExecutionListenerTests {
Object obj = new Object();
Hooks.onLastOperator("CUSTOM_HOOK", (p) -> Mono.just(obj));
this.listener.afterTestMethod(this.testContext);
Object result = Mono.subscriberContext().block();
Object result = Mono.deferContextual(Mono::just).block();
assertThat(result).isEqualTo(obj);
}