【发布时间】:2021-11-09 15:40:17
【问题描述】:
我正在尝试编写 IT。
mockMvc.perform( post( "/my_endpoint" )
.contentType( MediaType.APPLICATION_JSON )
.header("Authorization", my_credentials)
.with(csrf())
.content( jsonPayload )
)
.andExpect( status().isOk() );
我需要导入csrf()静态方法,但是通常创建的包(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors...)不再存在。
关于如何编写 csrf 保护以避免在测试中出现403 的一些新想法?
谢谢。
【问题讨论】:
标签: spring spring-boot integration-testing csrf