@Test public void testGetSecretOk() { when(persistentEngine.get(anyString())).thenReturn("value"); String result = underTest.get("secret"); Assert.assertEquals("value", result); }
public String get(String secret) { if (secret == null) { return null; } metricService.incrementMetricCounter(() -> "secret.read." + convertSecretToMetric(secret)); long start = System.currentTimeMillis(); String response = vaultRetryService.tryReadingVault(() -> { return getFirstEngineStream(secret) .map(e -> e.get(secret)) .filter(Objects::nonNull) .orElse(null); }); long duration = System.currentTimeMillis() - start; metricService.submit(MetricType.VAULT_READ, duration); LOGGER.trace("Secret read took {} ms", duration); return "null".equals(response) ? null : response; }
SecretService { public String get(String secret) { if (secret == null) { return null; } metricService.incrementMetricCounter(() -> "secret.read." + convertSecretToMetric(secret)); long start = System.currentTimeMillis(); String response = vaultRetryService.tryReadingVault(() -> { return getFirstEngineStream(secret) .map(e -> e.get(secret)) .filter(Objects::nonNull) .orElse(null); }); long duration = System.currentTimeMillis() - start; metricService.submit(MetricType.VAULT_READ, duration); LOGGER.trace("Secret read took {} ms", duration); return "null".equals(response) ? null : response; } }
SecretService { public String get(String secret) { if (secret == null) { return null; } metricService.incrementMetricCounter(() -> "secret.read." + convertSecretToMetric(secret)); long start = System.currentTimeMillis(); String response = vaultRetryService.tryReadingVault(() -> { return getFirstEngineStream(secret) .map(e -> e.get(secret)) .filter(Objects::nonNull) .orElse(null); }); long duration = System.currentTimeMillis() - start; metricService.submit(MetricType.VAULT_READ, duration); LOGGER.trace("Secret read took {} ms", duration); return "null".equals(response) ? null : response; } SecretService(MetricService metricService, List<SecretEngine> engines, VaultRetryService vaultRetryService); }
SecretService { public String get(String secret) { if (secret == null) { return null; } metricService.incrementMetricCounter(() -> "secret.read." + convertSecretToMetric(secret)); long start = System.currentTimeMillis(); String response = vaultRetryService.tryReadingVault(() -> { return getFirstEngineStream(secret) .map(e -> e.get(secret)) .filter(Objects::nonNull) .orElse(null); }); long duration = System.currentTimeMillis() - start; metricService.submit(MetricType.VAULT_READ, duration); LOGGER.trace("Secret read took {} ms", duration); return "null".equals(response) ? null : response; } SecretService(MetricService metricService, List<SecretEngine> engines, VaultRetryService vaultRetryService); @PostConstruct void init(); String put(String key, String value); String get(String secret); String getByResponse(SecretResponse secretResponse); void delete(String secret); List<String> listEntries(String secretPathPrefix); void cleanup(String pathPrefix); boolean isSecret(String secret); SecretResponse convertToExternal(String secret); }
SecretService { public String get(String secret) { if (secret == null) { return null; } metricService.incrementMetricCounter(() -> "secret.read." + convertSecretToMetric(secret)); long start = System.currentTimeMillis(); String response = vaultRetryService.tryReadingVault(() -> { return getFirstEngineStream(secret) .map(e -> e.get(secret)) .filter(Objects::nonNull) .orElse(null); }); long duration = System.currentTimeMillis() - start; metricService.submit(MetricType.VAULT_READ, duration); LOGGER.trace("Secret read took {} ms", duration); return "null".equals(response) ? null : response; } SecretService(MetricService metricService, List<SecretEngine> engines, VaultRetryService vaultRetryService); @PostConstruct void init(); String put(String key, String value); String get(String secret); String getByResponse(SecretResponse secretResponse); void delete(String secret); List<String> listEntries(String secretPathPrefix); void cleanup(String pathPrefix); boolean isSecret(String secret); SecretResponse convertToExternal(String secret);  }