Spring Security 5.7 has deprecated WebSecurityConfigurerAdapter in favour of SecurityFilterChain, but the Boot test configuration does not load it by default.
Instead, the configuration containing these beans now needs to be @Imported manually to ensure a correctly-configured MockMvc.
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
Comment From: wilkinsona
Duplicates #31162.