@ -82,9 +82,12 @@ import org.springframework.web.reactive.result.method.annotation.RequestMappingH
import org.springframework.web.reactive.result.view.ViewResolutionResultHandler ;
import org.springframework.web.reactive.result.view.ViewResolver ;
import org.springframework.web.server.ServerWebExchange ;
import org.springframework.web.server.WebSession ;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder ;
import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver ;
import org.springframework.web.server.i18n.FixedLocaleContextResolver ;
import org.springframework.web.server.i18n.LocaleContextResolver ;
import org.springframework.web.server.session.WebSessionManager ;
import org.springframework.web.util.pattern.PathPattern ;
import static org.assertj.core.api.Assertions.assertThat ;
@ -122,6 +125,8 @@ class WebFluxAutoConfigurationTests {
assertThat ( context ) . getBeans ( RequestMappingHandlerAdapter . class ) . hasSize ( 1 ) ;
assertThat ( context ) . getBeans ( RequestedContentTypeResolver . class ) . hasSize ( 1 ) ;
assertThat ( context ) . getBeans ( RouterFunctionMapping . class ) . hasSize ( 1 ) ;
assertThat ( context . getBean ( WebHttpHandlerBuilder . WEB_SESSION_MANAGER_BEAN_NAME , WebSessionManager . class ) )
. isNotNull ( ) ;
assertThat ( context . getBean ( "resourceHandlerMapping" , HandlerMapping . class ) ) . isNotNull ( ) ;
} ) ;
}
@ -557,6 +562,20 @@ class WebFluxAutoConfigurationTests {
HighPrecedenceConfigurer . class , WebFluxConfig . class , LowPrecedenceConfigurer . class ) ) ;
}
@Test
void customSameSteConfigurationShouldBeApplied ( ) {
this . contextRunner . withPropertyValues ( "spring.webflux.session.cookie.same-site:strict" ) . run ( ( context ) - > {
MockServerHttpRequest request = MockServerHttpRequest . get ( "/" ) . build ( ) ;
MockServerWebExchange exchange = MockServerWebExchange . from ( request ) ;
WebSessionManager webSessionManager = context . getBean ( WebSessionManager . class ) ;
WebSession webSession = webSessionManager . getSession ( exchange ) . block ( ) ;
webSession . start ( ) ;
exchange . getResponse ( ) . setComplete ( ) . block ( ) ;
assertThat ( exchange . getResponse ( ) . getCookies ( ) . get ( "SESSION" ) ) . isNotEmpty ( )
. allMatch ( ( cookie ) - > cookie . getSameSite ( ) . equals ( "Strict" ) ) ;
} ) ;
}
private Map < PathPattern , Object > getHandlerMap ( ApplicationContext context ) {
HandlerMapping mapping = context . getBean ( "resourceHandlerMapping" , HandlerMapping . class ) ;
if ( mapping instanceof SimpleUrlHandlerMapping ) {