Mono.currentContext()->subscriberContext()

Fixing refactoring by Reactor
This commit is contained in:
Rob Winch 2017-09-01 17:12:39 -05:00
parent 72f139a824
commit d9bad2bc9d
4 changed files with 11 additions and 11 deletions

View File

@ -80,7 +80,7 @@ public class EnableWebFluxSecurityTests {
chain.filter(exchange.mutate().principal(Mono.just(currentPrincipal)).build()),
springSecurityFilterChain,
(exchange,chain) ->
Mono.currentContext()
Mono.subscriberContext()
.flatMap( c -> c.<Mono<Principal>>get(Authentication.class))
.flatMap( principal -> exchange.getResponse()
.writeWith(Mono.just(toDataBuffer(principal.getName()))))
@ -99,7 +99,7 @@ public class EnableWebFluxSecurityTests {
WebTestClient client = WebTestClientBuilder.bindToWebFilters(
springSecurityFilterChain,
(exchange,chain) ->
Mono.currentContext()
Mono.subscriberContext()
.flatMap( c -> c.<Mono<Principal>>get(Authentication.class))
.flatMap( principal -> exchange.getResponse()
.writeWith(Mono.just(toDataBuffer(principal.getName()))))
@ -139,7 +139,7 @@ public class EnableWebFluxSecurityTests {
WebTestClient client = WebTestClientBuilder.bindToWebFilters(
springSecurityFilterChain,
(exchange,chain) ->
Mono.currentContext()
Mono.subscriberContext()
.flatMap( c -> c.<Mono<Principal>>get(Authentication.class))
.flatMap( principal -> exchange.getResponse()
.writeWith(Mono.just(toDataBuffer(principal.getName()))))

View File

@ -42,7 +42,7 @@ public class SecurityTestExecutionListenerTests {
@WithMockUser
@Test
public void reactorContextTestSecurityContextHolderExecutionListenerTestIsRegistered() {
Mono<String> name = Mono.currentContext()
Mono<String> name = Mono.subscriberContext()
.flatMap( context -> context.<Mono<Authentication>>get(Authentication.class))
.map(Principal::getName);

View File

@ -60,7 +60,7 @@ public class ReactorContextTestExecutionListenerTests {
public void beforeTestMethodWhenSecurityContextEmptyThenReactorContextNull() throws Exception {
this.listener.beforeTestMethod(this.testContext);
assertThat(Mono.currentContext().block().isEmpty()).isTrue();
assertThat(Mono.subscriberContext().block().isEmpty()).isTrue();
}
@Test
@ -69,7 +69,7 @@ public class ReactorContextTestExecutionListenerTests {
this.listener.beforeTestMethod(this.testContext);
assertThat(Mono.currentContext().block().isEmpty()).isTrue();
assertThat(Mono.subscriberContext().block().isEmpty()).isTrue();
}
@ -98,7 +98,7 @@ public class ReactorContextTestExecutionListenerTests {
this.listener.afterTestMethod(this.testContext);
assertThat(Mono.currentContext().block().isEmpty()).isTrue();
assertThat(Mono.subscriberContext().block().isEmpty()).isTrue();
}
@Test
@ -110,7 +110,7 @@ public class ReactorContextTestExecutionListenerTests {
}
public void assertAuthentication(Authentication expected) {
Mono<Authentication> authentication = Mono.currentContext()
Mono<Authentication> authentication = Mono.subscriberContext()
.flatMap( context -> context.<Mono<Authentication>>get(Authentication.class));
StepVerifier.create(authentication)

View File

@ -48,7 +48,7 @@ public class AuthenticationReactorContextFilterTests {
exchange = exchange.mutate().principal(Mono.just(principal)).build();
StepVerifier.create(filter.filter(exchange,
new DefaultWebFilterChain( e ->
Mono.currentContext().doOnSuccess( context -> {
Mono.subscriberContext().doOnSuccess( context -> {
Principal contextPrincipal = context.<Mono<Principal>>get(Authentication.class).block();
assertThat(contextPrincipal).isEqualTo(principal);
assertThat(context.<String>get("foo")).isEqualTo("bar");
@ -65,7 +65,7 @@ public class AuthenticationReactorContextFilterTests {
exchange = exchange.mutate().principal(Mono.just(principal)).build();
StepVerifier.create(filter.filter(exchange,
new DefaultWebFilterChain( e ->
Mono.currentContext().doOnSuccess( context -> {
Mono.subscriberContext().doOnSuccess( context -> {
Principal contextPrincipal = context.<Mono<Principal>>get(Authentication.class).block();
assertThat(contextPrincipal).isEqualTo(principal);
})
@ -80,7 +80,7 @@ public class AuthenticationReactorContextFilterTests {
Context defaultContext = Context.empty();
StepVerifier.create(filter.filter(exchange,
new DefaultWebFilterChain( e ->
Mono.currentContext()
Mono.subscriberContext()
.defaultIfEmpty(defaultContext)
.doOnSuccess( context -> {
Principal contextPrincipal = context.<Mono<Principal>>get(Authentication.class).block();