Spring Security, JUnit: @WithUserDetails for user created in @Before

前端 未结 3 1448
梦谈多话
梦谈多话 2021-02-12 14:25

In JUnit tests with Spring MockMVC, there are two methods for authenticating as a Spring Security user: @WithMockUser creates a dummy user with the provided credent

3条回答
  •  花落未央
    2021-02-12 15:01

    You can use @PostConstruct instead of @Before. That did the trick for me. Can anybody confirm that?

提交回复
热议问题