-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
Expected behaviour
Beans of type WebSecurityCustomizer are created during test execution when using @WebMvcTest.
Context
In Spring Security there are two ways to customize WebSecurity.
1st - use WebSecurityConfigurer, which was previously implemented by already deprecated and removed WebSecurityConfigurerAdapter.
2nd - since Spring Security 5.4 we can use WebSecurityCustomizer instead of WebSecurityConfigurerAdapter.
Beans of type WebSecurityCustomizer are used by WebSecurityConfiguration to execute actual customization.
When I use @WebMvcTest I want my custom WebSecurityCustomizer to be picked up by the framework automatically during test execution.
However, since WebMvcTypeExcludeFilter doesn't include such beans - they are ignored/filtered out:
Lines 54 to 56 in 4be3dc2
| private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule", | |
| "org.springframework.security.config.annotation.web.WebSecurityConfigurer", | |
| "org.springframework.security.web.SecurityFilterChain", "org.thymeleaf.dialect.IDialect" }; |
Should beans of type WebSecurityCustomizer be included in the OPTIONAL_INCLUDES array similar to WebSecurityConfigurer?