Search in sources :

Example 1 with PayloadInterceptorChain

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();
}
Also used : DefaultPayloadExchange(org.springframework.security.rsocket.core.DefaultPayloadExchange) PayloadExchange(org.springframework.security.rsocket.api.PayloadExchange) PayloadInterceptorChain(org.springframework.security.rsocket.api.PayloadInterceptorChain) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1 PayloadExchange (org.springframework.security.rsocket.api.PayloadExchange)1 PayloadInterceptorChain (org.springframework.security.rsocket.api.PayloadInterceptorChain)1 DefaultPayloadExchange (org.springframework.security.rsocket.core.DefaultPayloadExchange)1