Spring Test returning 401 for unsecured URLs

后端 未结 4 1583
北荒
北荒 2020-12-07 00:38

I am using Spring for MVC tests

Here is my test class

@RunWith(SpringRunner.class)
@WebMvcTest
public class ITIndexController {

    @Autowired
    W         


        
4条回答
  •  温柔的废话
    2020-12-07 01:18

    Not sure if this was available when the original question was asked, but if truly not wanting to test the security portion of a web request (which seems reasonable if the endpoint is known to be unsecure), then I think this could be done simply by using the secure attribute of the @WebMvcTest annotation (it defaults to true so setting it to false should disable the auto-configuration of Spring Security's MockMvc support):

    @WebMvcTest(secure = false)
    

    More info available in the javadocs

提交回复
热议问题