@Test public void testScarifySecretEndsWithNotUUID() { VaultSecret secret = new VaultSecret("cb", "com.sequenceiq.cloudbreak.service.secret.vault.VaultKvV1Engine", "cb/foo/bar"); String result = underTest.scarifySecret(gson.toJson(secret)); Assert.assertEquals("cb.foo.bar", result); }
@Override public String scarifySecret(String secret) { VaultSecret vaultSecret = convertToVaultSecret(secret); int cut = uniqueId.matcher(vaultSecret.getPath()).matches() ? 1 : 0; return Optional.of(vaultSecret) .map(s -> s.getPath().split("/")) .map(ss -> Stream.of(ss).limit(ss.length - cut)) .map(st -> st.collect(Collectors.joining("."))) .orElse(null); }
AbstractVaultEngine implements SecretEngine { @Override public String scarifySecret(String secret) { VaultSecret vaultSecret = convertToVaultSecret(secret); int cut = uniqueId.matcher(vaultSecret.getPath()).matches() ? 1 : 0; return Optional.of(vaultSecret) .map(s -> s.getPath().split("/")) .map(ss -> Stream.of(ss).limit(ss.length - cut)) .map(st -> st.collect(Collectors.joining("."))) .orElse(null); } }
AbstractVaultEngine implements SecretEngine { @Override public String scarifySecret(String secret) { VaultSecret vaultSecret = convertToVaultSecret(secret); int cut = uniqueId.matcher(vaultSecret.getPath()).matches() ? 1 : 0; return Optional.of(vaultSecret) .map(s -> s.getPath().split("/")) .map(ss -> Stream.of(ss).limit(ss.length - cut)) .map(st -> st.collect(Collectors.joining("."))) .orElse(null); }  }
AbstractVaultEngine implements SecretEngine { @Override public String scarifySecret(String secret) { VaultSecret vaultSecret = convertToVaultSecret(secret); int cut = uniqueId.matcher(vaultSecret.getPath()).matches() ? 1 : 0; return Optional.of(vaultSecret) .map(s -> s.getPath().split("/")) .map(ss -> Stream.of(ss).limit(ss.length - cut)) .map(st -> st.collect(Collectors.joining("."))) .orElse(null); }  @Override boolean isSecret(String secret); @Override String scarifySecret(String secret); }
AbstractVaultEngine implements SecretEngine { @Override public String scarifySecret(String secret) { VaultSecret vaultSecret = convertToVaultSecret(secret); int cut = uniqueId.matcher(vaultSecret.getPath()).matches() ? 1 : 0; return Optional.of(vaultSecret) .map(s -> s.getPath().split("/")) .map(ss -> Stream.of(ss).limit(ss.length - cut)) .map(st -> st.collect(Collectors.joining("."))) .orElse(null); }  @Override boolean isSecret(String secret); @Override String scarifySecret(String secret);  }