@Test public void testDownload() throws IOException { Object downloads = ConfigFactory.parseString( AppSettings.SECRET_MANAGER_DOWNLOADS + "=[" + "{" + "secret = \"projects/" + projectId + "/secrets/secretstuff/versions/latest\"," + "file = \"" + secretsDirectory.resolve("secretstuff.txt") + "\"" + "}" + "]").getAnyRef(AppSettings.SECRET_MANAGER_DOWNLOADS); try(SettingsOverride override = SettingsOverride.apply(Map.of(AppSettings.SECRET_MANAGER_DOWNLOADS, downloads))) { SecretManager.downloadSecrets(); String contents = Files.readString(secretsDirectory.resolve("secretstuff.txt")); assertEquals(contents, "This is secret stuff"); } }
public static void downloadSecrets() { List<? extends Config> downloads = AppSettings.getInstance().getConfigList(AppSettings.SECRET_MANAGER_DOWNLOADS); if (downloads.size() > 0) { for (Config download : downloads) { boolean required; try { required = download.getBoolean("required"); } catch (ConfigException.Missing e) { required = true; } downloadSecret(download.getString("secret"), download.getString("file"), required); } } }
SecretManager { public static void downloadSecrets() { List<? extends Config> downloads = AppSettings.getInstance().getConfigList(AppSettings.SECRET_MANAGER_DOWNLOADS); if (downloads.size() > 0) { for (Config download : downloads) { boolean required; try { required = download.getBoolean("required"); } catch (ConfigException.Missing e) { required = true; } downloadSecret(download.getString("secret"), download.getString("file"), required); } } } }
SecretManager { public static void downloadSecrets() { List<? extends Config> downloads = AppSettings.getInstance().getConfigList(AppSettings.SECRET_MANAGER_DOWNLOADS); if (downloads.size() > 0) { for (Config download : downloads) { boolean required; try { required = download.getBoolean("required"); } catch (ConfigException.Missing e) { required = true; } downloadSecret(download.getString("secret"), download.getString("file"), required); } } }  }
SecretManager { public static void downloadSecrets() { List<? extends Config> downloads = AppSettings.getInstance().getConfigList(AppSettings.SECRET_MANAGER_DOWNLOADS); if (downloads.size() > 0) { for (Config download : downloads) { boolean required; try { required = download.getBoolean("required"); } catch (ConfigException.Missing e) { required = true; } downloadSecret(download.getString("secret"), download.getString("file"), required); } } }  static void downloadSecrets(); }
SecretManager { public static void downloadSecrets() { List<? extends Config> downloads = AppSettings.getInstance().getConfigList(AppSettings.SECRET_MANAGER_DOWNLOADS); if (downloads.size() > 0) { for (Config download : downloads) { boolean required; try { required = download.getBoolean("required"); } catch (ConfigException.Missing e) { required = true; } downloadSecret(download.getString("secret"), download.getString("file"), required); } } }  static void downloadSecrets();  }