小编nai*_*bes的帖子

使用WebTestClient在springBootTest中禁用安全性

2.1发行说明中的​​SpringBoot包含以下信息:

安全配置现在应用于WebTestClient.有关测试安全端点的更多信息,请参阅Spring Security参考文档的相关部分.

问题:

将SpringBoot从2.0.4更新到2.1.2后,我发现我的测试已经停止工作了.我正在使用@SpringBootTest我的REST测试.我WebTestClient无法到达服务器.我确实尝试了很多(例如从这里)来模拟或禁用安全性并仍然得到403 FORBIDDEN响应.

你有什么线索可能有什么不对吗?

我WebTestClient按以下方式创建:

client = WebTestClient
  .bindToServer()
  .baseUrl("http://localhost:$port")
  .build()
Run Code Online (Sandbox Code Playgroud)

也试图排除SecurityAutoConfiguration.class.

java spring spring-security spring-boot

7
推荐指数
1
解决办法
501
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-security ×1