@Test void shouldWorkWhenRegistryIsReloadedAndVaultIsUnSealed() throws InterruptedException { VaultInstance sealedVaultInstance = vaultContainerExtension.startNewVaultInstance(); sealedVaultInstance.putSecrets( VAULT_SECRETS_PATH1, "top_secret=password1", "db_password=dbpassword1"); String address = sealedVaultInstance.address(); String unsealKey = sealedVaultInstance.unsealKey(); String rootToken = sealedVaultInstance.rootToken(); ConfigRegistrySettings settings = ConfigRegistrySettings.builder() .addLastSource( "vault", VaultConfigSource.builder() .config(vaultConfig -> vaultConfig.address(address).token(rootToken)) .secretsPath(VAULT_SECRETS_PATH1) .build()) .jmxEnabled(false) .reloadIntervalSec(1) .build(); ConfigRegistry configRegistry = ConfigRegistry.create(settings); StringConfigProperty configProperty = configRegistry.stringProperty("top_secret"); assertThat( "initial value of top_secret", configProperty.value().get(), containsString("password1")); Vault vault = sealedVaultInstance.vault(); Map<String, Object> newValues = new HashMap<>(); newValues.put(configProperty.name(), "new_password"); try { vault.logical().write(VAULT_SECRETS_PATH1, newValues); vault.seal().seal(); assumeTrue(vault.seal().sealStatus().getSealed(), "vault seal status"); } catch (VaultException vaultException) { fail(vaultException.getMessage()); } TimeUnit.SECONDS.sleep(2); assumeFalse( configProperty.value().isPresent() && configProperty.value().get().contains("new_password"), "new value was unexpectedly set"); try { vault.seal().unseal(unsealKey); assumeFalse(vault.seal().sealStatus().getSealed(), "vault seal status"); } catch (VaultException vaultException) { fail(vaultException.getMessage()); } TimeUnit.SECONDS.sleep(2); assertThat(configProperty.value().get(), containsString("new_password")); }
public static Builder builder() { return new Builder(); }
VaultConfigSource implements ConfigSource { public static Builder builder() { return new Builder(); } }
VaultConfigSource implements ConfigSource { public static Builder builder() { return new Builder(); } private  VaultConfigSource(VaultInvoker vault, Collection<String> secretsPaths); }
VaultConfigSource implements ConfigSource { public static Builder builder() { return new Builder(); } private  VaultConfigSource(VaultInvoker vault, Collection<String> secretsPaths); @Override Map<String, ConfigProperty> loadConfig(); static Builder builder(); }
VaultConfigSource implements ConfigSource { public static Builder builder() { return new Builder(); } private  VaultConfigSource(VaultInvoker vault, Collection<String> secretsPaths); @Override Map<String, ConfigProperty> loadConfig(); static Builder builder();  }