Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing actuator endpoint authorization with webclient throws exception [SPR-17059] #21597

Closed
spring-projects-issues opened this issue Jul 18, 2018 · 2 comments
Assignees
Labels
status: invalid

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jul 18, 2018

Georg Mittendorfer opened SPR-17059 and commented

I try to test my actuator endpoints. I followed the instructions here: https://docs.spring.io/spring-security/site/docs/current/reference/html5/#test-webflux

My actuator endpoint is secured as follows:

@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
  return http.authorizeExchange()
    .matchers(EndpointRequest.toAnyEndpoint()).hasRole("ENDPOINT_ADMIN") // throws
    .anyExchange().authenticated()
    .and().httpBasic()
    .and().formLogin()
    .and().csrf().disable()
    .build();
}

That works (HTTP 200/401/403) when running the application. But the following tests (some examples) do not work (HTTP 500)"

@Test
public void whenActuatorInfoThen401Unauthorized() {
  restClient.get().uri("/actuator/info").exchange().expectStatus().isUnauthorized();
}

@WithMockUser(roles = "ENDPOINT_ADMIN")
@Test
public void givenEndpointAdminWhenActuatorInfoThen200Ok() {
  restClient.get().uri("/actuator/info").exchange().expectStatus().isOk();
}

@Test
public void whenUnknownPathThen401Unauthorized() {
  restClient.get().uri("/foo/bar").exchange().expectStatus().isUnauthorized();
}

@WithMockUser
@Test
public void givenUserWhenUnknownPathThen404NotFound() {
  restClient.get().uri("/foo/bar").exchange().expectStatus().isNotFound();
}

I get:

 

16:59:36.257 [main] ERROR o.s.b.a.w.r.e.DefaultErrorWebExceptionHandler - Failed to handle request [GET /actuator/info]
java.lang.IllegalStateException: No WebApplicationContext found.
	at org.springframework.util.Assert.state(Assert.java:73)
	at org.springframework.boot.security.reactive.ApplicationContextServerWebExchangeMatcher.createContext(ApplicationContextServerWebExchangeMatcher.java:91)
	at org.springframework.boot.security.reactive.ApplicationContextServerWebExchangeMatcher.getContext(ApplicationContextServerWebExchangeMatcher.java:73)
	at org.springframework.boot.security.reactive.ApplicationContextServerWebExchangeMatcher.matches(ApplicationContextServerWebExchangeMatcher.java:57)
	at org.springframework.security.web.server.util.matcher.OrServerWebExchangeMatcher.lambda$matches$0(OrServerWebExchangeMatcher.java:51)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:347)
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:244)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:202)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
	at reactor.core.publisher.FluxFilter.subscribe(FluxFilter.java:52)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:418)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:210)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxConcatMap.subscribe(FluxConcatMap.java:121)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoDefaultIfEmpty.subscribe(MonoDefaultIfEmpty.java:37)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:78)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onComplete(ReactorContextTestExecutionListener.java:114)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:1642)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1454)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1328)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onSubscribe(ReactorContextTestExecutionListener.java:99)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:96)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.checkTerminated(FluxFlatMap.java:773)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:543)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:523)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onComplete(FluxFlatMap.java:409)
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:266)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:202)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
	at reactor.core.publisher.FluxFilter.subscribe(FluxFilter.java:52)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1083)
	at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onComplete(FluxDefaultIfEmpty.java:100)
	at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:130)
	at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:130)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onComplete(FluxMap.java:245)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1085)
	at reactor.core.publisher.MonoProcessor.onNext(MonoProcessor.java:389)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onNext(ReactorContextTestExecutionListener.java:104)
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:185)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onNext(ReactorContextTestExecutionListener.java:104)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1083)
	at reactor.core.publisher.MonoSupplier.subscribe(MonoSupplier.java:61)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:96)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:349)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onComplete(FluxConcatMap.java:265)
	at reactor.core.publisher.Operators.complete(Operators.java:128)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:123)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxConcatMap.subscribe(FluxConcatMap.java:121)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoPeek.subscribe(MonoPeek.java:71)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoProcessor.add(MonoProcessor.java:531)
	at reactor.core.publisher.MonoProcessor.subscribe(MonoProcessor.java:444)
	at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:52)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55)
	at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55)
	at reactor.core.publisher.MonoDefaultIfEmpty.subscribe(MonoDefaultIfEmpty.java:37)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:78)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onComplete(ReactorContextTestExecutionListener.java:114)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:1642)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1454)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1328)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onSubscribe(ReactorContextTestExecutionListener.java:99)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:96)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.checkTerminated(FluxFlatMap.java:773)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:543)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:523)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onComplete(FluxFlatMap.java:409)
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:266)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:202)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
	at reactor.core.publisher.FluxFilter.subscribe(FluxFilter.java:52)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:78)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onComplete(ReactorContextTestExecutionListener.java:114)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:1642)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1454)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1328)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onSubscribe(ReactorContextTestExecutionListener.java:99)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:96)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.checkTerminated(FluxFlatMap.java:773)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:543)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:523)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onComplete(FluxFlatMap.java:409)
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:266)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:202)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
	at reactor.core.publisher.FluxFilter.subscribe(FluxFilter.java:52)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onComplete(MonoFlatMap.java:174)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:78)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onComplete(ReactorContextTestExecutionListener.java:114)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:1642)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1454)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1328)
	at org.springframework.security.test.context.support.ReactorContextTestExecutionListener$DelegateTestExecutionListener$SecuritySubContext.onSubscribe(ReactorContextTestExecutionListener.java:99)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:96)
	at reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:142)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.checkTerminated(FluxFlatMap.java:773)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:543)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:523)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onComplete(FluxFlatMap.java:409)
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:266)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:202)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97)
	at reactor.core.publisher.FluxFilter.subscribe(FluxFilter.java:52)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFilter.subscribe(MonoFilter.java:46)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:141)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onNext(FluxFilterFuseable.java:104)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:1640)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.request(FluxFilterFuseable.java:170)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:103)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:79)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.MonoFilterFuseable.subscribe(MonoFilterFuseable.java:47)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoSubscriberContext.subscribe(MonoSubscriberContext.java:47)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:115)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:115)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1083)
	at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:241)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1083)
	at reactor.core.publisher.MonoCollectList$MonoBufferAllSubscriber.onComplete(MonoCollectList.java:117)
	at reactor.core.publisher.FluxIterable$IterableSubscription.fastPath(FluxIterable.java:334)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:199)
	at reactor.core.publisher.MonoCollectList$MonoBufferAllSubscriber.onSubscribe(MonoCollectList.java:90)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.MonoCollectList.subscribe(MonoCollectList.java:59)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
	at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
	at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76)
	at reactor.core.publisher.FluxFilterWhen$FluxFilterWhenSubscriber.drain(FluxFilterWhen.java:287)
	at reactor.core.publisher.FluxFilterWhen$FluxFilterWhenSubscriber.onNext(FluxFilterWhen.java:131)
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:244)
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:202)
	at reactor.core.publisher.FluxFilterWhen$FluxFilterWhenSubscriber.onSubscribe(FluxFilterWhen.java:190)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:140)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:64)
	at reactor.core.publisher.FluxFilterWhen.subscribe(FluxFilterWhen.java:68)
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
	at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)
	at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
	at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
	at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
	at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.MonoLiftFuseable.subscribe(MonoLiftFuseable.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.Mono.subscribeWith(Mono.java:3188)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3074)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3041)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3013)
	at org.springframework.test.web.reactive.server.HttpHandlerConnector.lambda$connect$1(HttpHandlerConnector.java:89)
	at org.springframework.mock.http.client.reactive.MockClientHttpRequest.lambda$null$2(MockClientHttpRequest.java:125)
	at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:45)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.FluxConcatIterable$ConcatIterableSubscriber.onComplete(FluxConcatIterable.java:147)
	at reactor.core.publisher.FluxConcatIterable.subscribe(FluxConcatIterable.java:61)
	at reactor.core.publisher.MonoSourceFlux.subscribe(MonoSourceFlux.java:47)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
	at reactor.core.publisher.Mono.subscribeWith(Mono.java:3188)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3074)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3041)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3013)
	at org.springframework.test.web.reactive.server.HttpHandlerConnector.connect(HttpHandlerConnector.java:100)
	at org.springframework.test.web.reactive.server.WiretapConnector.connect(WiretapConnector.java:73)
	at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.exchange(ExchangeFunctions.java:79)
	at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:141)
	at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:53)
	at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
	at reactor.core.publisher.MonoLift.subscribe(MonoLift.java:46)
	at reactor.core.publisher.Mono.block(Mono.java:1198)
	at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultRequestBodyUriSpec.exchange(DefaultWebTestClient.java:282)

By replacing the the matcher in the configuration with a path matcher everything works as expected:

[...]
.pathMatchers("/actuator", "/actuator/*").hasRole("ENDPOINT_ADMIN") // working
[...]

Disclaimer: I am not sure if this is a bug or simply a mistake I made in my test. If it was the latter please ignore.


Affects: 5.0.6

Issue Links:

  • #21510 The WebHttpHandlerBuilder copy constructor does not copy the applicationcontext ("duplicates")
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 19, 2018

Brian Clozel commented

Hi Georg Mittendorfer,

If you're not sure this is a bug, could you make this a StackOverflow question? Even if it is a bug, this should then belong in the Spring Boot issue tracker.

Also, we're missing key information information here: what's your testing setup? Code snippets are showing the tests themselves, but not how the test class is configured nor where the web client comes from.

Thanks,

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 19, 2018

Georg Mittendorfer commented

I don't have any questions and don't need the fix as the workaround I posted is sufficient for me. I just wanted to help to improve the quality as I believe it is a bug (but how can I be sure if it is?).

Thanks for the hint with regard to the test setup. Maybe the anchor of the link was not exact (correct: https://docs.spring.io/spring-security/site/docs/current/reference/html5/#test-webtestclient) and not complete enough.

Opened issue: https://github.com/spring-projects/spring-boot/issues/13826 

Edit: might be duplicate of #21510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid
Projects
None yet
Development

No branches or pull requests

2 participants