Testing secured reactive Spring Boot applications is similar to testing imperative applications. Before starting, we need to add new dependencies, including Spring Security Test and Testcontainers Keycloak. The dependency adding JUnit5 support for Testcontainers is already there. Open the 'build.gradle' file and update it as follows. Remember to refresh and reimport the Gradle dependencies after the new addition.

We can implement full integration tests using '@SpringBootTest' and Testcontainers Keycloak. Since the setup is the same as for Catalog Service, I won't cover those tests here, but you can find them in the repository accompanying the book (Chapter12/12-end/order-service/src/test). Make sure you update those integration tests, or the application build will fail.

In this section, we'll test the web slice of a reactive application when the endpoints are secured, much like we did for Catalog Service.


原文地址: https://www.cveoy.top/t/topic/p5Pg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录