Disable security in springBootTest using WebTestClient
In some dark place, deep down the rabbit hole I found this:
@TestConfiguration
@Order(1)
public class SecurityConfiguration
implements WebSecurityConfigurer<WebSecurity> {
@Override
public void init(WebSecurity builder) throws Exception {
builder.ignoring().requestMatchers(
new AntPathRequestMatcher("/**"));
}
@Override
public void configure(WebSecurity builder) throws Exception {
}
}
Remember to register class in @SpringBootTest
, for instance:
@SpringBootTest(
classes = [SomeApplication, SecurityConfiguration],
webEnvironment = RANDOM_PORT
)
It's not disabling spring security, but it makes it transparent.