Search in sources :

Example 1 with RSocketServerCustomizer

use of org.springframework.boot.rsocket.server.RSocketServerCustomizer in project spring-boot by spring-projects.

the class NettyRSocketServerFactoryTests method serverCustomizers.

@Test
void serverCustomizers() {
    NettyRSocketServerFactory factory = getFactory();
    RSocketServerCustomizer[] customizers = new RSocketServerCustomizer[2];
    for (int i = 0; i < customizers.length; i++) {
        customizers[i] = mock(RSocketServerCustomizer.class);
        will((invocation) -> invocation.getArgument(0)).given(customizers[i]).customize(any(io.rsocket.core.RSocketServer.class));
    }
    factory.setRSocketServerCustomizers(Arrays.asList(customizers));
    this.server = factory.create(new EchoRequestResponseAcceptor());
    InOrder ordered = inOrder((Object[]) customizers);
    for (RSocketServerCustomizer customizer : customizers) {
        ordered.verify(customizer).customize(any(io.rsocket.core.RSocketServer.class));
    }
}
Also used : InOrder(org.mockito.InOrder) RSocketServer(org.springframework.boot.rsocket.server.RSocketServer) RSocketServerCustomizer(org.springframework.boot.rsocket.server.RSocketServerCustomizer) Test(org.junit.jupiter.api.Test)

Example 2 with RSocketServerCustomizer

use of org.springframework.boot.rsocket.server.RSocketServerCustomizer in project spring-boot by spring-projects.

the class RSocketSecurityAutoConfigurationTests method autoConfigurationAddsCustomizerForServerRSocketFactory.

@Test
void autoConfigurationAddsCustomizerForServerRSocketFactory() {
    RSocketServer server = RSocketServer.create();
    this.contextRunner.run((context) -> {
        RSocketServerCustomizer customizer = context.getBean(RSocketServerCustomizer.class);
        customizer.customize(server);
        server.interceptors((registry) -> registry.forSocketAcceptor((interceptors) -> {
            assertThat(interceptors).isNotEmpty();
            assertThat(interceptors).anyMatch((interceptor) -> interceptor instanceof SecuritySocketAcceptorInterceptor);
        }));
    });
}
Also used : ReactiveUserDetailsServiceAutoConfiguration(org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration) AutoConfigurations(org.springframework.boot.autoconfigure.AutoConfigurations) RSocketMessageHandler(org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler) RSocketServerCustomizer(org.springframework.boot.rsocket.server.RSocketServerCustomizer) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) AuthenticationPrincipalArgumentResolver(org.springframework.security.messaging.handler.invocation.reactive.AuthenticationPrincipalArgumentResolver) SecuritySocketAcceptorInterceptor(org.springframework.security.rsocket.core.SecuritySocketAcceptorInterceptor) RSocketServer(io.rsocket.core.RSocketServer) Test(org.junit.jupiter.api.Test) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) RSocketSecurity(org.springframework.security.config.annotation.rsocket.RSocketSecurity) RSocketMessagingAutoConfiguration(org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration) RSocketStrategiesAutoConfiguration(org.springframework.boot.autoconfigure.rsocket.RSocketStrategiesAutoConfiguration) RSocketServer(io.rsocket.core.RSocketServer) SecuritySocketAcceptorInterceptor(org.springframework.security.rsocket.core.SecuritySocketAcceptorInterceptor) RSocketServerCustomizer(org.springframework.boot.rsocket.server.RSocketServerCustomizer) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 RSocketServerCustomizer (org.springframework.boot.rsocket.server.RSocketServerCustomizer)2 RSocketServer (io.rsocket.core.RSocketServer)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 InOrder (org.mockito.InOrder)1 AutoConfigurations (org.springframework.boot.autoconfigure.AutoConfigurations)1 RSocketMessagingAutoConfiguration (org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration)1 RSocketStrategiesAutoConfiguration (org.springframework.boot.autoconfigure.rsocket.RSocketStrategiesAutoConfiguration)1 ReactiveUserDetailsServiceAutoConfiguration (org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration)1 RSocketServer (org.springframework.boot.rsocket.server.RSocketServer)1 FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)1 ApplicationContextRunner (org.springframework.boot.test.context.runner.ApplicationContextRunner)1 RSocketMessageHandler (org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler)1 RSocketSecurity (org.springframework.security.config.annotation.rsocket.RSocketSecurity)1 AuthenticationPrincipalArgumentResolver (org.springframework.security.messaging.handler.invocation.reactive.AuthenticationPrincipalArgumentResolver)1 SecuritySocketAcceptorInterceptor (org.springframework.security.rsocket.core.SecuritySocketAcceptorInterceptor)1