This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-20775 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8596a8e1e66ada063bf018ef98fa123a849a9dd3 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon May 20 14:55:43 2024 +0200 CAMEL-20775 - camel-hashicorp-vault - configure multiple engines Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../vault/HashicorpVaultPropertiesFunction.java | 64 +++++++------ .../HashicorpVaultPropertiesSourceNoEnvTestIT.java | 87 +++++++---------- .../HashicorpVaultPropertiesSourceTestIT.java | 104 ++++++--------------- .../camel/vault/HashicorpVaultConfiguration.java | 13 --- .../HashicorpVaultConfigurationConfigurer.java | 3 - ...corpVaultConfigurationPropertiesConfigurer.java | 3 - .../HashicorpVaultConfigurationProperties.java | 8 -- .../java/org/apache/camel/main/MainVaultTest.java | 2 - 8 files changed, 99 insertions(+), 185 deletions(-) diff --git a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultPropertiesFunction.java b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultPropertiesFunction.java index 63489033c6f..598c14ae226 100644 --- a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultPropertiesFunction.java +++ b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultPropertiesFunction.java @@ -38,7 +38,6 @@ import org.springframework.vault.support.VaultResponse; * credentials and service location: * <ul> * <li><tt>CAMEL_HASHICORP_VAULT_TOKEN_ENV</tt></li> - * <li><tt>CAMEL_HASHICORP_VAULT_ENGINE_ENV</tt></li> * <li><tt>CAMEL_HASHICORP_VAULT_HOST_ENV</tt></li> * <li><tt>CAMEL_HASHICORP_VAULT_PORT_ENV</tt></li> * <li><tt>CAMEL_HASHICORP_VAULT_SCHEME_ENV</tt></li> @@ -49,7 +48,6 @@ import org.springframework.vault.support.VaultResponse; * * <ul> * <li><tt>camel.vault.hashicorp.token</tt></li> - * <li><tt>camel.vault.hashicorp.engine</tt></li> * <li><tt>camel.vault.hashicorp.host</tt></li> * <li><tt>camel.vault.hashicorp.port</tt></li> * <li><tt>camel.vault.hashicorp.scheme</tt></li> @@ -57,22 +55,22 @@ import org.springframework.vault.support.VaultResponse; * <p/> * * This implementation is to return the secret value associated with a key. The properties related to this kind of - * Properties Function are all prefixed with <tt>hashicorp:</tt>. For example asking for <tt>hashicorp:token</tt>, will - * return the secret value associated to the secret named token on Hashicorp Vault instance. + * Properties Function are all prefixed with <tt>hashicorp:</tt>. For example asking for + * <tt>hashicorp:engine:token</tt>, will return the secret value associated to the secret named token on Hashicorp Vault + * instance on the engine 'engine'. * - * Another way of retrieving a secret value is using the following notation <tt>hashicorp:database/username</tt>: in - * this case the field username of the secret database will be returned. As a fallback, the user could provide a default - * value, which will be returned in case the secret doesn't exist, the secret has been marked for deletion or, for - * example, if a particular field of the secret doesn't exist. For using this feature, the user could use the following - * notation <tt>aws:database/username:admin</tt>. The admin value will be returned as default value, if the conditions - * above were all met. + * Another way of retrieving a secret value is using the following notation <tt>hashicorp:engine:database/username</tt>: + * in this case the field username of the secret database will be returned. As a fallback, the user could provide a + * default value, which will be returned in case the secret doesn't exist, the secret has been marked for deletion or, + * for example, if a particular field of the secret doesn't exist. For using this feature, the user could use the + * following notation <tt>hashicorp:engine:database/username:admin</tt>. The admin value will be returned as default + * value, if the conditions above were all met. */ @org.apache.camel.spi.annotations.PropertiesFunction("hashicorp") public class HashicorpVaultPropertiesFunction extends ServiceSupport implements PropertiesFunction, CamelContextAware { private static final String CAMEL_HASHICORP_VAULT_TOKEN_ENV = "CAMEL_HASHICORP_VAULT_TOKEN"; - private static final String CAMEL_HASHICORP_VAULT_ENGINE_ENV = "CAMEL_HASHICORP_VAULT_ENGINE"; private static final String CAMEL_HASHICORP_VAULT_HOST_ENV = "CAMEL_HASHICORP_VAULT_HOST"; private static final String CAMEL_HASHICORP_VAULT_PORT_ENV = "CAMEL_HASHICORP_VAULT_PORT"; @@ -87,22 +85,20 @@ public class HashicorpVaultPropertiesFunction extends ServiceSupport implements protected void doStart() throws Exception { super.doStart(); String token = System.getenv(CAMEL_HASHICORP_VAULT_TOKEN_ENV); - engine = System.getenv(CAMEL_HASHICORP_VAULT_ENGINE_ENV); String host = System.getenv(CAMEL_HASHICORP_VAULT_HOST_ENV); String port = System.getenv(CAMEL_HASHICORP_VAULT_PORT_ENV); String scheme = System.getenv(CAMEL_HASHICORP_VAULT_SCHEME_ENV); - if (ObjectHelper.isEmpty(token) && ObjectHelper.isEmpty(engine) && ObjectHelper.isEmpty(host) + if (ObjectHelper.isEmpty(token) && ObjectHelper.isEmpty(host) && ObjectHelper.isEmpty(port) && ObjectHelper.isEmpty(scheme)) { HashicorpVaultConfiguration hashicorpVaultConfiguration = getCamelContext().getVaultConfiguration().hashicorp(); if (ObjectHelper.isNotEmpty(hashicorpVaultConfiguration)) { token = hashicorpVaultConfiguration.getToken(); - engine = hashicorpVaultConfiguration.getEngine(); host = hashicorpVaultConfiguration.getHost(); port = hashicorpVaultConfiguration.getPort(); scheme = hashicorpVaultConfiguration.getScheme(); } } - if (ObjectHelper.isNotEmpty(token) && ObjectHelper.isNotEmpty(engine) && ObjectHelper.isNotEmpty(host) + if (ObjectHelper.isNotEmpty(token) && ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port) && ObjectHelper.isNotEmpty(scheme)) { VaultEndpoint vaultEndpoint = new VaultEndpoint(); vaultEndpoint.setHost(host); @@ -114,7 +110,7 @@ public class HashicorpVaultPropertiesFunction extends ServiceSupport implements new TokenAuthentication(token)); } else { throw new RuntimeCamelException( - "Using the Hashicorp Properties Function requires setting Engine, Token, Host, port and scheme properties"); + "Using the Hashicorp Properties Function requires setting Token, Host, port and scheme properties"); } } @@ -131,7 +127,9 @@ public class HashicorpVaultPropertiesFunction extends ServiceSupport implements String defaultValue = null; String version = null; if (remainder.contains("/")) { - key = StringHelper.before(remainder, "/"); + String keyRemainder = StringHelper.before(remainder, "/"); + engine = StringHelper.before(keyRemainder, ":"); + key = StringHelper.after(keyRemainder, ":"); subkey = StringHelper.after(remainder, "/"); defaultValue = StringHelper.after(subkey, ":"); if (ObjectHelper.isNotEmpty(defaultValue)) { @@ -148,16 +146,28 @@ public class HashicorpVaultPropertiesFunction extends ServiceSupport implements subkey = StringHelper.before(subkey, "@"); } } else if (remainder.contains(":")) { - key = StringHelper.before(remainder, ":"); - defaultValue = StringHelper.after(remainder, ":"); - if (remainder.contains("@")) { - version = StringHelper.after(remainder, "@"); - defaultValue = StringHelper.before(defaultValue, "@"); - } - } else { - if (remainder.contains("@")) { - key = StringHelper.before(remainder, "@"); - version = StringHelper.after(remainder, "@"); + engine = StringHelper.before(remainder, ":"); + key = StringHelper.after(remainder, ":"); + if (key.contains(":")) { + defaultValue = StringHelper.after(key, ":"); + if (ObjectHelper.isNotEmpty(defaultValue)) { + if (defaultValue.contains("@")) { + version = StringHelper.after(defaultValue, "@"); + defaultValue = StringHelper.before(defaultValue, "@"); + } + } + if (key.contains(":")) { + key = StringHelper.before(key, ":"); + } + if (key.contains("@")) { + version = StringHelper.after(key, "@"); + key = StringHelper.before(key, "@"); + } + } else { + if (key.contains("@")) { + version = StringHelper.after(key, "@"); + key = StringHelper.before(key, "@"); + } } } diff --git a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceNoEnvTestIT.java b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceNoEnvTestIT.java index 8893fd6d800..6eead4ad217 100644 --- a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceNoEnvTestIT.java +++ b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceNoEnvTestIT.java @@ -26,12 +26,10 @@ import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import static org.junit.jupiter.api.Assertions.assertThrows; -// Must be manually tested. Provide your own accessKey and secretKey using -Dcamel.vault.hashicorp.token, -Dcamel.vault.hashicorp.engine, -Dcamel.vault.hashicorp.host, -Dcamel.vault.hashicorp.port and -Dcamel.vault.hashicorp.scheme +// Must be manually tested. Provide your own accessKey and secretKey using -Dcamel.vault.hashicorp.token, -Dcamel.vault.hashicorp.host, -Dcamel.vault.hashicorp.port and -Dcamel.vault.hashicorp.scheme @EnabledIfSystemProperties({ @EnabledIfSystemProperty(named = "camel.vault.hashicorp.token", matches = ".*", disabledReason = "Token not provided"), - @EnabledIfSystemProperty(named = "camel.vault.hashicorp.engine", matches = ".*", - disabledReason = "Engine not provided"), @EnabledIfSystemProperty(named = "camel.vault.hashicorp.host", matches = ".*", disabledReason = "Host not provided"), @EnabledIfSystemProperty(named = "camel.vault.hashicorp.port", matches = ".*", disabledReason = "Port not provided"), @EnabledIfSystemProperty(named = "camel.vault.hashicorp.scheme", matches = ".*", disabledReason = "Scheme not provided") @@ -41,14 +39,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testFunctio() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:start").setBody(simple("{{hashicorp:hello}}")).to("mock:bar"); + from("direct:start").setBody(simple("{{hashicorp:secret:hello}}")).to("mock:bar"); } }); context.start(); @@ -63,14 +60,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testFunctionWithField() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:start").setBody(simple("{{hashicorp:hello/id}}")).to("mock:bar"); + from("direct:start").setBody(simple("{{hashicorp:secret:hello/id}}")).to("mock:bar"); } }); context.start(); @@ -85,15 +81,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testComplexCustomPropertiesFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:hello/username}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:hello/password}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:hello/username}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:hello/password}}")).to("mock:bar"); } }); context.start(); @@ -109,14 +104,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport public void testSecretNotFoundFunction() { Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:start").setBody(simple("{{hashicorp:testExample}}")).to("mock:bar"); + from("direct:start").setBody(simple("{{hashicorp:secret:testExample}}")).to("mock:bar"); } }); context.start(); @@ -133,14 +127,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport public void testComplexNoSubkeyPropertiesFunction() { Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:database_sample/not_existent}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:database_sample/not_existent}}")).to("mock:bar"); } }); context.start(); @@ -155,15 +148,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testComplexCustomPropertiesDefaultValueFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:hello/additional1:admin}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:hello/additional2:secret}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:hello/additional1:admin}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:hello/additional2:secret}}")).to("mock:bar"); } }); context.start(); @@ -178,15 +170,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testComplexCustomPropertiesDefaultValueExceptionFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:test-3/additional1:admin}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:test-3/additional2:secret}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:test-3/additional1:admin}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:test-3/additional2:secret}}")).to("mock:bar"); } }); context.start(); @@ -202,15 +193,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport public void testComplexCustomPropertiesExceptionFunction() { Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:test-3/additional1}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:test-3/additional2}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:test-3/additional1}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:test-3/additional2}}")).to("mock:bar"); } }); context.start(); @@ -226,15 +216,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testComplexSimpleDefaultValueExceptionFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:hello-2:admin}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:hello-1:secret}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:hello-2:admin}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:hello-1:secret}}")).to("mock:bar"); } }); context.start(); @@ -250,14 +239,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport public void testComplexSimpleNoDefaultValueExceptionFunction() { Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:secretsuper}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:secretsuper}}")).to("mock:bar"); } }); context.start(); @@ -273,15 +261,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport public void testComplexCustomPropertiesNoDefaultValueFunction() { Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:postgresql/additional1}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:postgresql/additional2}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:postgresql/additional1}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:postgresql/additional2}}")).to("mock:bar"); } }); context.start(); @@ -297,14 +284,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testComplexCustomPropertiesNotExistentDefaultValueFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:newsecret/additional1:admin}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:newsecret/additional1:admin}}")).to("mock:bar"); } }); context.start(); @@ -318,14 +304,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testComplexCustomPropertiesDefaultCredsDefaultValueFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:newsecret/additional1:admin}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:newsecret/additional1:admin}}")).to("mock:bar"); } }); context.start(); @@ -339,15 +324,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithDefaultFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:postgresql/username:oscerd}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:postgresql/password:password}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:postgresql/username:oscerd}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:postgresql/password:password}}")).to("mock:bar"); } }); context.start(); @@ -362,15 +346,14 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithDefaultNotExistentFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:db_sample/username:oscerd}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:db_sample/password:password}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:db_sample/username:oscerd}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:db_sample/password:password}}")).to("mock:bar"); } }); context.start(); @@ -385,14 +368,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithVersionFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello/id@1}}")).to("mock:bar"); + from("direct:version").setBody(simple("{{hashicorp:secret:hello/id@1}}")).to("mock:bar"); } }); context.start(); @@ -406,19 +388,18 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithVersionAndNoFieldFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello@1}}")).to("mock:bar"); + from("direct:version").setBody(simple("{{hashicorp:secret:hello@1}}")).to("mock:bar"); } }); context.start(); - getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}"); + getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21, password=password, username=admin}"); template.sendBody("direct:version", "Hello World"); MockEndpoint.assertIsSatisfied(context); @@ -427,20 +408,19 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithVersionNoFieldAndDefaultValueFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello:pippo@1}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello:pippo@1}}")) .to("mock:bar"); } }); context.start(); - getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}"); + getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21, password=password, username=admin}"); template.sendBody("direct:version", "Hello World"); MockEndpoint.assertIsSatisfied(context); @@ -449,14 +429,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithVersionNoFieldDefaultValueNotExistentSecretFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello-3:pippo@4}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello-3:pippo@4}}")) .to("mock:bar"); } }); @@ -471,14 +450,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithVersionNoFieldDefaultValueNotExistentVersionFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello:pippo@4}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello:pippo@4}}")) .to("mock:bar"); } }); @@ -493,14 +471,13 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport @Test public void testPropertiesWithVersionFieldAndDefaultValueFunction() throws Exception { context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token")); - context.getVaultConfiguration().hashicorp().setEngine(System.getProperty("camel.vault.hashicorp.engine")); context.getVaultConfiguration().hashicorp().setHost(System.getProperty("camel.vault.hashicorp.host")); context.getVaultConfiguration().hashicorp().setPort(System.getProperty("camel.vault.hashicorp.port")); context.getVaultConfiguration().hashicorp().setScheme(System.getProperty("camel.vault.hashicorp.scheme")); context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello/id:pippo@1}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello/id:pippo@1}}")) .to("mock:bar"); } }); diff --git a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceTestIT.java b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceTestIT.java index 6a6d32222f6..911e9269d3e 100644 --- a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceTestIT.java +++ b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceTestIT.java @@ -28,7 +28,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -37,7 +36,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:start").setBody(simple("{{hashicorp:hello}}")).to("mock:bar"); + from("direct:start").setBody(simple("{{hashicorp:secret:hello}}")).to("mock:bar"); } }); context.start(); @@ -50,7 +49,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -59,7 +57,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:start").setBody(simple("{{hashicorp:hello/id}}")).to("mock:bar"); + from("direct:start").setBody(simple("{{hashicorp:secret:hello/id}}")).to("mock:bar"); } }); context.start(); @@ -72,7 +70,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -81,8 +78,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:hello/username}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:hello/password}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:hello/username}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:hello/password}}")).to("mock:bar"); } }); context.start(); @@ -95,31 +92,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") - @Test - public void testSecretNotFoundFunction() { - Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { - context.addRoutes(new RouteBuilder() { - @Override - public void configure() { - from("direct:start").setBody(simple("{{hashicorp:testExample}}")).to("mock:bar"); - } - }); - context.start(); - - getMockEndpoint("mock:bar").expectedBodiesReceived("hello"); - - template.sendBody("direct:start", "Hello World"); - - MockEndpoint.assertIsSatisfied(context); - }); - } - - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -142,7 +114,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -151,8 +122,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:hello/additional1:admin}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:hello/additional2:secret}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:hello/additional1:admin}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:hello/additional2:secret}}")).to("mock:bar"); } }); context.start(); @@ -165,7 +136,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -174,8 +144,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:test-3/additional1:admin}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:test-3/additional2:secret}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:test-3/additional1:admin}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:test-3/additional2:secret}}")).to("mock:bar"); } }); context.start(); @@ -188,7 +158,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -198,8 +167,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:test-3/additional1}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:test-3/additional2}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:test-3/additional1}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:test-3/additional2}}")).to("mock:bar"); } }); context.start(); @@ -213,7 +182,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -222,13 +190,13 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:hello-2:admin}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:hello-1:secret}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:hello-2:admin}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:hello-1:pwd}}")).to("mock:bar"); } }); context.start(); - getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret"); + getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "pwd"); template.sendBody("direct:username", "Hello World"); template.sendBody("direct:password", "Hello World"); @@ -236,7 +204,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -246,7 +213,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:secretsuper}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:secretsuper}}")).to("mock:bar"); } }); context.start(); @@ -259,7 +226,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -269,8 +235,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:postgresql/additional1}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:postgresql/additional2}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:postgresql/additional1}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:postgresql/additional2}}")).to("mock:bar"); } }); context.start(); @@ -284,7 +250,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -293,7 +258,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:newsecret/additional1:admin}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:newsecret/additional1:admin}}")).to("mock:bar"); } }); context.start(); @@ -305,7 +270,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -314,7 +278,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:newsecret/additional1:admin}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:newsecret/additional1:admin}}")).to("mock:bar"); } }); context.start(); @@ -326,7 +290,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -335,8 +298,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:postgresql/username:oscerd}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:postgresql/password:password}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:postgresql/username:oscerd}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:postgresql/password:password}}")).to("mock:bar"); } }); context.start(); @@ -349,7 +312,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -358,8 +320,8 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:username").setBody(simple("{{hashicorp:db_sample/username:oscerd}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{hashicorp:db_sample/password:password}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{hashicorp:secret:db_sample/username:oscerd}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{hashicorp:secret:db_sample/password:password}}")).to("mock:bar"); } }); context.start(); @@ -372,7 +334,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -381,7 +342,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello/id@1}}")).to("mock:bar"); + from("direct:version").setBody(simple("{{hashicorp:secret:hello/id@1}}")).to("mock:bar"); } }); context.start(); @@ -393,7 +354,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -402,19 +362,18 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello@1}}")).to("mock:bar"); + from("direct:version").setBody(simple("{{hashicorp:secret:hello@1}}")).to("mock:bar"); } }); context.start(); - getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}"); + getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21, password=password, username=admin}"); template.sendBody("direct:version", "Hello World"); MockEndpoint.assertIsSatisfied(context); } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -423,20 +382,19 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello:pippo@1}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello:pippo@1}}")) .to("mock:bar"); } }); context.start(); - getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}"); + getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21, password=password, username=admin}"); template.sendBody("direct:version", "Hello World"); MockEndpoint.assertIsSatisfied(context); } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -445,7 +403,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello-3:pippo@4}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello-3:pippo@4}}")) .to("mock:bar"); } }); @@ -458,7 +416,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -467,7 +424,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello:pippo@4}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello:pippo@4}}")) .to("mock:bar"); } }); @@ -480,7 +437,6 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { } @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", matches = ".*") - @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_ENGINE", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_HOST", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*") @@ -489,7 +445,7 @@ public class HashicorpVaultPropertiesSourceTestIT extends CamelTestSupport { context.addRoutes(new RouteBuilder() { @Override public void configure() { - from("direct:version").setBody(simple("{{hashicorp:hello/id:pippo@1}}")) + from("direct:version").setBody(simple("{{hashicorp:secret:hello/id:pippo@1}}")) .to("mock:bar"); } }); diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java index d3215fcb311..6b8cb816109 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java @@ -25,8 +25,6 @@ public class HashicorpVaultConfiguration extends VaultConfiguration { @Metadata(secret = true) private String token; - @Metadata(secret = true) - private String engine; @Metadata private String host; @Metadata @@ -45,17 +43,6 @@ public class HashicorpVaultConfiguration extends VaultConfiguration { this.token = token; } - /** - * Engine to look at hashicorp vault - */ - public String getEngine() { - return engine; - } - - public void setEngine(String engine) { - this.engine = engine; - } - /** * Host to access hashicorp vault */ diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationConfigurer.java index e2349ebb107..7146b673c2c 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationConfigurer.java @@ -27,7 +27,6 @@ public class HashicorpVaultConfigurationConfigurer extends org.apache.camel.supp case "awsVaultConfiguration": target.setAwsVaultConfiguration(property(camelContext, org.apache.camel.vault.AwsVaultConfiguration.class, value)); return true; case "azurevaultconfiguration": case "azureVaultConfiguration": target.setAzureVaultConfiguration(property(camelContext, org.apache.camel.vault.AzureVaultConfiguration.class, value)); return true; - case "engine": target.setEngine(property(camelContext, java.lang.String.class, value)); return true; case "gcpvaultconfiguration": case "gcpVaultConfiguration": target.setGcpVaultConfiguration(property(camelContext, org.apache.camel.vault.GcpVaultConfiguration.class, value)); return true; case "hashicorpvaultconfiguration": @@ -47,7 +46,6 @@ public class HashicorpVaultConfigurationConfigurer extends org.apache.camel.supp case "awsVaultConfiguration": return org.apache.camel.vault.AwsVaultConfiguration.class; case "azurevaultconfiguration": case "azureVaultConfiguration": return org.apache.camel.vault.AzureVaultConfiguration.class; - case "engine": return java.lang.String.class; case "gcpvaultconfiguration": case "gcpVaultConfiguration": return org.apache.camel.vault.GcpVaultConfiguration.class; case "hashicorpvaultconfiguration": @@ -68,7 +66,6 @@ public class HashicorpVaultConfigurationConfigurer extends org.apache.camel.supp case "awsVaultConfiguration": return target.getAwsVaultConfiguration(); case "azurevaultconfiguration": case "azureVaultConfiguration": return target.getAzureVaultConfiguration(); - case "engine": return target.getEngine(); case "gcpvaultconfiguration": case "gcpVaultConfiguration": return target.getGcpVaultConfiguration(); case "hashicorpvaultconfiguration": diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java index e715833f154..1a6a1553522 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/HashicorpVaultConfigurationPropertiesConfigurer.java @@ -27,7 +27,6 @@ public class HashicorpVaultConfigurationPropertiesConfigurer extends org.apache. case "awsVaultConfiguration": target.setAwsVaultConfiguration(property(camelContext, org.apache.camel.vault.AwsVaultConfiguration.class, value)); return true; case "azurevaultconfiguration": case "azureVaultConfiguration": target.setAzureVaultConfiguration(property(camelContext, org.apache.camel.vault.AzureVaultConfiguration.class, value)); return true; - case "engine": target.setEngine(property(camelContext, java.lang.String.class, value)); return true; case "gcpvaultconfiguration": case "gcpVaultConfiguration": target.setGcpVaultConfiguration(property(camelContext, org.apache.camel.vault.GcpVaultConfiguration.class, value)); return true; case "hashicorpvaultconfiguration": @@ -47,7 +46,6 @@ public class HashicorpVaultConfigurationPropertiesConfigurer extends org.apache. case "awsVaultConfiguration": return org.apache.camel.vault.AwsVaultConfiguration.class; case "azurevaultconfiguration": case "azureVaultConfiguration": return org.apache.camel.vault.AzureVaultConfiguration.class; - case "engine": return java.lang.String.class; case "gcpvaultconfiguration": case "gcpVaultConfiguration": return org.apache.camel.vault.GcpVaultConfiguration.class; case "hashicorpvaultconfiguration": @@ -68,7 +66,6 @@ public class HashicorpVaultConfigurationPropertiesConfigurer extends org.apache. case "awsVaultConfiguration": return target.getAwsVaultConfiguration(); case "azurevaultconfiguration": case "azureVaultConfiguration": return target.getAzureVaultConfiguration(); - case "engine": return target.getEngine(); case "gcpvaultconfiguration": case "gcpVaultConfiguration": return target.getGcpVaultConfiguration(); case "hashicorpvaultconfiguration": diff --git a/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java index 86d6423ea39..04490af8409 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/HashicorpVaultConfigurationProperties.java @@ -57,14 +57,6 @@ public class HashicorpVaultConfigurationProperties extends HashicorpVaultConfigu return this; } - /** - * The Hashicorp vault Engine to look at - */ - public HashicorpVaultConfigurationProperties withEngine(String engine) { - setEngine(engine); - return this; - } - /** * The Hashicorp Vault host */ diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java index 862f616ece6..312725ae10b 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java @@ -241,7 +241,6 @@ public class MainVaultTest { Main main = new Main(); main.addInitialProperty("camel.vault.hashicorp.token", "1111"); - main.addInitialProperty("camel.vault.hashicorp.engine", "sec"); main.addInitialProperty("camel.vault.hashicorp.host", "localhost"); main.addInitialProperty("camel.vault.hashicorp.port", "8200"); main.addInitialProperty("camel.vault.hashicorp.scheme", "https"); @@ -254,7 +253,6 @@ public class MainVaultTest { assertNotNull(cfg); Assertions.assertEquals("1111", cfg.getToken()); - Assertions.assertEquals("sec", cfg.getEngine()); Assertions.assertEquals("localhost", cfg.getHost()); Assertions.assertEquals("8200", cfg.getPort()); Assertions.assertEquals("https", cfg.getScheme());