I\'m trying to test @WebMvcTest
with custom security settings defined in SecurityConfig
class:
@Configuration
@EnableWebSecurity
p
WebMvcTest
is only going to load your controller and nothing else (that's why we call that slicing). We can't figure out which part of your configuration you want and which one you don't. If the security config isn't on your main @SpringBootApplication
you'll have to import it explicitly. Otherwise, Spring Boot is going to enable default security settings.
If you're using something like OAuth, that's a good thing though because you really don't want to start using that for a mock test. What happens if you add @Import(SecurityConfig.class)
to your test?