use of org.springframework.security.rsocket.api.PayloadInterceptorChain in project spring-security by spring-projects.
the class AuthenticationPayloadInterceptorTests method interceptWhenAuthenticationSuccessThenChainSubscribedOnce.
@Test
public void interceptWhenAuthenticationSuccessThenChainSubscribedOnce() {
AuthenticationPayloadInterceptor interceptor = new AuthenticationPayloadInterceptor(this.authenticationManager);
PayloadExchange exchange = createExchange();
TestingAuthenticationToken expectedAuthentication = new TestingAuthenticationToken("user", "password");
given(this.authenticationManager.authenticate(any())).willReturn(Mono.just(expectedAuthentication));
PublisherProbe<Void> voidResult = PublisherProbe.empty();
PayloadInterceptorChain chain = mock(PayloadInterceptorChain.class);
given(chain.next(any())).willReturn(voidResult.mono());
StepVerifier.create(interceptor.intercept(exchange, chain)).then(() -> assertThat(voidResult.subscribeCount()).isEqualTo(1)).verifyComplete();
}
Aggregations