0

Config file processing has been changed in Spring Boot 2.4. It allows to eliminate bootstrap configuration and use spring.config.import instead together with some specific locations like vault://…​. Internally it uses ConfigDataLocationResolver and ConfigDataLoader from the org.springframework.boot.context.config package.

We are using Spring Cloud Vault to load secrets during service startup

application.yml

spring.config.import: vault://...

It works perfectly and allows to eliminate all complexity related to bootstrap.yml but not sure how to create integration tests using SpringBootTest. For Vault we need to mock VaultTemplate bean that is instantiated in VaultConfigDataLoader

Currently we are using separate org.springframework.cloud.bootstrap.BootstrapConfiguration in META-INF/spring.factories to mock such beans but ideally we want to disable bootstrap completely and rely on a new config file lifecycle.

Are there any interceptors that allow to register mock bean before ConfigDataLoader without enabling bootstrap context?

Alex
  • 4,987
  • 1
  • 8
  • 26
  • You might want to look into disabling Vault integration during your test with a configuration property instead – nickb Jun 05 '23 at 19:29
  • Of course, we can disable it but the idea here is to validate vault configuration and make sure that secrets are loaded from the correct location. – Alex Jun 06 '23 at 01:40

0 Answers0