@AutoConfigureWebMvc currently imports the following auto-configuration classes (see spring.factories in the spring-boot-test-autoconfigure bank):
From this list, MockMvcSecurityAutoConfiguration will automatically provide integration with the security filter.
If you need to add support for additional filters, you can write your own MockMvcBuilderCustomizer (see MockMvcSecurityConfiguration.SecurityMockMvcBuilderCustomizer for inspiration).
You can use the @TestConfiguration nested class to bind your customizer to a specific test, you can add your own spring.factories and use the AutoConfigureMockMvc key to automatically add it to all tests.
source share