@Test public void decryptFileSecretEngineNotFound() throws SecretDecryptionException { when(secretEngineRegistry.getEngine("does-not-exist")).thenReturn(null); String secretConfig = "encrypted:does-not-exist!paramName:paramValue"; exceptionRule.expect(SecretDecryptionException.class); exceptionRule.expectMessage("Secret Engine does not exist: does-not-exist"); secretManager.decryptAsFile(secretConfig); }
public Path decryptAsFile(String filePathOrEncrypted) { if (!EncryptedSecret.isEncryptedSecret(filePathOrEncrypted)) { return Paths.get(filePathOrEncrypted); } else { return createTempFile("tmp", decryptAsBytes(filePathOrEncrypted)); } }
SecretManager { public Path decryptAsFile(String filePathOrEncrypted) { if (!EncryptedSecret.isEncryptedSecret(filePathOrEncrypted)) { return Paths.get(filePathOrEncrypted); } else { return createTempFile("tmp", decryptAsBytes(filePathOrEncrypted)); } } }
SecretManager { public Path decryptAsFile(String filePathOrEncrypted) { if (!EncryptedSecret.isEncryptedSecret(filePathOrEncrypted)) { return Paths.get(filePathOrEncrypted); } else { return createTempFile("tmp", decryptAsBytes(filePathOrEncrypted)); } } @Autowired  SecretManager(SecretEngineRegistry secretEngineRegistry); }
SecretManager { public Path decryptAsFile(String filePathOrEncrypted) { if (!EncryptedSecret.isEncryptedSecret(filePathOrEncrypted)) { return Paths.get(filePathOrEncrypted); } else { return createTempFile("tmp", decryptAsBytes(filePathOrEncrypted)); } } @Autowired  SecretManager(SecretEngineRegistry secretEngineRegistry); String decrypt(String configValue); Path decryptAsFile(String filePathOrEncrypted); byte[] decryptAsBytes(String encryptedString); }
SecretManager { public Path decryptAsFile(String filePathOrEncrypted) { if (!EncryptedSecret.isEncryptedSecret(filePathOrEncrypted)) { return Paths.get(filePathOrEncrypted); } else { return createTempFile("tmp", decryptAsBytes(filePathOrEncrypted)); } } @Autowired  SecretManager(SecretEngineRegistry secretEngineRegistry); String decrypt(String configValue); Path decryptAsFile(String filePathOrEncrypted); byte[] decryptAsBytes(String encryptedString);  }