|
22 | 22 | import javax.servlet.DispatcherType;
|
23 | 23 |
|
24 | 24 | import org.junit.jupiter.api.Test;
|
| 25 | +import org.mockito.InOrder; |
25 | 26 |
|
26 | 27 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
27 | 28 | import org.springframework.boot.autoconfigure.web.ServerProperties;
|
|
30 | 31 | import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
31 | 32 | import org.springframework.context.annotation.Bean;
|
32 | 33 | import org.springframework.context.annotation.Configuration;
|
| 34 | +import org.springframework.core.annotation.Order; |
33 | 35 | import org.springframework.session.MapSessionRepository;
|
34 | 36 | import org.springframework.session.SessionRepository;
|
35 | 37 | import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
|
|
42 | 44 | import org.springframework.test.util.ReflectionTestUtils;
|
43 | 45 |
|
44 | 46 | import static org.assertj.core.api.Assertions.assertThat;
|
| 47 | +import static org.mockito.ArgumentMatchers.any; |
| 48 | +import static org.mockito.Mockito.inOrder; |
45 | 49 | import static org.mockito.Mockito.mock;
|
46 | 50 |
|
47 | 51 | /**
|
@@ -205,6 +209,16 @@ void autoConfiguredCookieSerializerIsConfiguredWithRememberMeRequestAttribute()
|
205 | 209 | });
|
206 | 210 | }
|
207 | 211 |
|
| 212 | + @Test |
| 213 | + void cookieSerializerCustomization() { |
| 214 | + this.contextRunner.withBean(CookieSerializerCustomization.class).run((context) -> { |
| 215 | + CookieSerializerCustomization customization = context.getBean(CookieSerializerCustomization.class); |
| 216 | + InOrder inOrder = inOrder(customization.customizer1, customization.customizer2); |
| 217 | + inOrder.verify(customization.customizer1).customize(any()); |
| 218 | + inOrder.verify(customization.customizer2).customize(any()); |
| 219 | + }); |
| 220 | + } |
| 221 | + |
208 | 222 | @Configuration(proxyBeanMethods = false)
|
209 | 223 | @EnableSpringHttpSession
|
210 | 224 | static class SessionRepositoryConfiguration {
|
@@ -276,4 +290,26 @@ SpringSessionRememberMeServices rememberMeServices() {
|
276 | 290 |
|
277 | 291 | }
|
278 | 292 |
|
| 293 | + @Configuration(proxyBeanMethods = false) |
| 294 | + @EnableSpringHttpSession |
| 295 | + static class CookieSerializerCustomization extends SessionRepositoryConfiguration { |
| 296 | + |
| 297 | + private final CookieSerializerCustomizer customizer1 = mock(CookieSerializerCustomizer.class); |
| 298 | + |
| 299 | + private final CookieSerializerCustomizer customizer2 = mock(CookieSerializerCustomizer.class); |
| 300 | + |
| 301 | + @Bean |
| 302 | + @Order(1) |
| 303 | + CookieSerializerCustomizer customizer1() { |
| 304 | + return this.customizer1; |
| 305 | + } |
| 306 | + |
| 307 | + @Bean |
| 308 | + @Order(2) |
| 309 | + CookieSerializerCustomizer customizer2() { |
| 310 | + return this.customizer2; |
| 311 | + } |
| 312 | + |
| 313 | + } |
| 314 | + |
279 | 315 | }
|
0 commit comments