我在集成测试中使用Spring WebFlux WebTestClient。我使用WebTestClient.bindToServer()创建客户端。测试服务器使用HTTPS服务资源。我有以下代码:
WebTestClient webTestClient = WebTestClient.bindToServer()
.baseUrl("https://secured.example.com")
.build();
webTestClient.get().uri("/index.html")
.exchange()
.expectStatus().isOk();在测试中不需要使用有效的证书。如何配置WebTestClient以信任所有证书?
我可以配置WebClient来信任每个人。但是WebTestClient更适合编写测试。
发布于 2017-11-08 16:19:53
您可以使用可以提供给WebTestClient的自定义WebTestClient来配置它。
// create a custom connector and customize TLS configuration there.
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(options -> options...);
WebTestClient client = WebTestClient.bindToServer(connector);这一点最近在SPR-16168中得到了修正。
https://stackoverflow.com/questions/46831656
复制相似问题