|
1 | 1 | /* |
2 | | - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2022 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
16 | 16 |
|
17 | 17 | package org.springframework.boot.autoconfigure.security.rsocket; |
18 | 18 |
|
| 19 | +import java.util.List; |
| 20 | + |
19 | 21 | import io.rsocket.core.RSocketServer; |
20 | 22 | import org.junit.jupiter.api.Test; |
21 | 23 |
|
22 | 24 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
| 25 | +import org.springframework.boot.autoconfigure.rsocket.RSocketMessageHandlerCustomizer; |
23 | 26 | import org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration; |
24 | 27 | import org.springframework.boot.autoconfigure.rsocket.RSocketStrategiesAutoConfiguration; |
25 | 28 | import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration; |
26 | 29 | import org.springframework.boot.rsocket.server.RSocketServerCustomizer; |
27 | 30 | import org.springframework.boot.test.context.FilteredClassLoader; |
28 | 31 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
| 32 | +import org.springframework.messaging.handler.invocation.reactive.HandlerMethodArgumentResolver; |
| 33 | +import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler; |
29 | 34 | import org.springframework.security.config.annotation.rsocket.RSocketSecurity; |
| 35 | +import org.springframework.security.messaging.handler.invocation.reactive.AuthenticationPrincipalArgumentResolver; |
30 | 36 | import org.springframework.security.rsocket.core.SecuritySocketAcceptorInterceptor; |
31 | 37 |
|
32 | 38 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -69,4 +75,19 @@ void autoConfigurationAddsCustomizerForServerRSocketFactory() { |
69 | 75 | }); |
70 | 76 | } |
71 | 77 |
|
| 78 | + @Test |
| 79 | + void autoConfigurationAddsCustomizerForMessageHandlerRSocketFactory() { |
| 80 | + RSocketMessageHandler handler = new RSocketMessageHandler(); |
| 81 | + this.contextRunner.run((context) -> { |
| 82 | + RSocketMessageHandlerCustomizer customizer = context.getBean(RSocketMessageHandlerCustomizer.class); |
| 83 | + customizer.customize(handler); |
| 84 | + |
| 85 | + List<HandlerMethodArgumentResolver> customResolvers = handler.getArgumentResolverConfigurer() |
| 86 | + .getCustomResolvers(); |
| 87 | + assertThat(customResolvers).isNotEmpty(); |
| 88 | + assertThat(customResolvers) |
| 89 | + .anyMatch((customResolver) -> customResolver instanceof AuthenticationPrincipalArgumentResolver); |
| 90 | + }); |
| 91 | + } |
| 92 | + |
72 | 93 | } |
0 commit comments