M
M
maxvinogradov2021-08-20 21:20:48
Java
maxvinogradov, 2021-08-20 21:20:48

Do I need to leave Spring Security in testing?

I need to test controllers, should I keep Spring Security? Certainly with the redefined user service that in a DB did not climb.
Is this generally an adequate solution to test controllers with security enabled?

Thanks a lot for your answer!

Or the third option, write something like this above each controller to turn it off altogether.

@WebMvcTest(controllers = AdminRestaurantController.class,
        excludeFilters  = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,
        classes = SecurityConfig.class),
        excludeAutoConfiguration = SecurityAutoConfiguration.class)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question