Errong Leng
📍 Langley, BC, Canada

why @WithMockUser still got 401 unauthorized

@AutoConfigureMockMvc for none reactive spring application, the Servlet API and Servlet containers, spring-boot-starter-web, please use MockMvc. import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) @AutoConfigureMockMvc @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class IntegrationTestsBase { @Autowired protected MockMvc mockMvc; ... mockMvc.perform(
1 min read

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.