You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/09/09 13:46:56 UTC
(camel) branch main updated (26dc7199cc9 -> 31adac593b6)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 26dc7199cc9 browsable (#15482)
new 58925a47151 CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
new 24154bc3398 CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
new 1ccc094dae2 CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
new 0060d7147de CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
new 31adac593b6 CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/main/docs/hashicorp-vault-component.adoc | 8 +-
.../vault/HashicorpVaultPropertiesFunction.java | 6 +-
.../HashicorpVaultPropertiesSourceNoEnvTestIT.java | 75 +++-
.../HashicorpVaultPropertiesSourceTestIT.java | 484 ---------------------
.../ROOT/pages/camel-4x-upgrade-guide-4_9.adoc | 14 +
docs/user-manual/modules/ROOT/pages/security.adoc | 6 +-
6 files changed, 93 insertions(+), 500 deletions(-)
delete mode 100644 components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceTestIT.java
(camel) 04/05: CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0060d7147de2411688242ca297285a946e301840
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 9 14:50:15 2024 +0200
CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
docs/user-manual/modules/ROOT/pages/security.adoc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/security.adoc b/docs/user-manual/modules/ROOT/pages/security.adoc
index 1f4a2f7c504..9b9c589e37a 100644
--- a/docs/user-manual/modules/ROOT/pages/security.adoc
+++ b/docs/user-manual/modules/ROOT/pages/security.adoc
@@ -491,7 +491,7 @@ You're able to do get single secret value in your route, in the 'secret' engine,
<camelContext>
<route>
<from uri="direct:start"/>
- <log message="Username is {{hashicorp:secret:database/username}}"/>
+ <log message="Username is {{hashicorp:secret:database#username}}"/>
</route>
</camelContext>
----
@@ -505,7 +505,7 @@ You could specify a default value in case the particular field of secret is not
<camelContext>
<route>
<from uri="direct:start"/>
- <log message="Username is {{hashicorp:secret:database/username:admin}}"/>
+ <log message="Username is {{hashicorp:secret:database#username:admin}}"/>
</route>
</camelContext>
----
@@ -543,7 +543,7 @@ This approach will return the route secret value with version '2' or default val
<camelContext>
<route>
<from uri="direct:start"/>
- <log message="Username is {{hashicorp:secret:database/username:admin@2}}"/>
+ <log message="Username is {{hashicorp:secret:database#username:admin@2}}"/>
</route>
</camelContext>
----
(camel) 03/05: CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1ccc094dae2c414237bbd230b3001efc16ba6ed1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 9 14:46:45 2024 +0200
CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../src/main/docs/hashicorp-vault-component.adoc | 8 ++++----
.../HashicorpVaultPropertiesSourceNoEnvTestIT.java | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/components/camel-hashicorp-vault/src/main/docs/hashicorp-vault-component.adoc b/components/camel-hashicorp-vault/src/main/docs/hashicorp-vault-component.adoc
index 6d4eb0ee59e..4a26193777f 100644
--- a/components/camel-hashicorp-vault/src/main/docs/hashicorp-vault-component.adoc
+++ b/components/camel-hashicorp-vault/src/main/docs/hashicorp-vault-component.adoc
@@ -123,7 +123,7 @@ You're able to do get single secret value in your route, in the 'secret' engine,
<camelContext>
<route>
<from uri="direct:start"/>
- <log message="Username is {{hashicorp:secret:database/username}}"/>
+ <log message="Username is {{hashicorp:secret:database#username}}"/>
</route>
</camelContext>
----
@@ -137,7 +137,7 @@ You could specify a default value in case the particular field of secret is not
<camelContext>
<route>
<from uri="direct:start"/>
- <log message="Username is {{hashicorp:secret:database/username:admin}}"/>
+ <log message="Username is {{hashicorp:secret:database#username:admin}}"/>
</route>
</camelContext>
----
@@ -175,7 +175,7 @@ This approach will return the route secret value with version '2' or default val
<camelContext>
<route>
<from uri="direct:start"/>
- <log message="Username is {{hashicorp:secret:database/username:admin@2}}"/>
+ <log message="Username is {{hashicorp:secret:database#username:admin@2}}"/>
</route>
</camelContext>
----
@@ -184,4 +184,4 @@ This approach will return the username field of the database secret with version
The only requirement is adding the camel-hashicorp-vault jar to your Camel application.
-include::spring-boot:partial$starter.adoc[]
\ No newline at end of file
+include::spring-boot:partial$starter.adoc[]
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 b1b1ae289f6..246c172491b 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
@@ -555,4 +555,25 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
template.sendBody("direct:engine2", "Hello World");
MockEndpoint.assertIsSatisfied(context);
}
+
+ @Test
+ public void testPropertiesWithVersionFieldAndDefaultValueWithVersion() throws Exception {
+ context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token"));
+ 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:secret:production/secrets/hello@1}}"))
+ .to("mock:bar");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}");
+
+ template.sendBody("direct:version", "Hello World");
+ MockEndpoint.assertIsSatisfied(context);
+ }
}
(camel) 05/05: CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 31adac593b6a430f8585e4f78d64c132f980ebe9
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 9 15:09:14 2024 +0200
CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
index 8a9d3f6aee0..76555562a45 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_9.adoc
@@ -10,3 +10,17 @@ from both 4.0 to 4.1 and 4.1 to 4.2.
The `queueSize` attribute on endpoints which are `ManagedBrowseableEndpoint` is changed from returning a `Long` value
to an `Integer` value.
+
+=== camel-hashicorp-vault properties function
+
+The syntax for retrieving a single field of a secret has been changed.
+
+From this
+
+`{{hashicorp:secret:database/username}}`
+
+to this
+
+`{{hashicorp:secret:database#username}}`
+
+You could find more details on CAMEL-21179 issue
(camel) 01/05: CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 58925a4715178e597b47a4b19bcf67cf66b6df1b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 9 14:33:06 2024 +0200
CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../vault/HashicorpVaultPropertiesFunction.java | 6 +-
.../HashicorpVaultPropertiesSourceNoEnvTestIT.java | 33 +-
.../HashicorpVaultPropertiesSourceTestIT.java | 484 ---------------------
3 files changed, 30 insertions(+), 493 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 598c14ae226..b54be20e34e 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
@@ -126,11 +126,11 @@ public class HashicorpVaultPropertiesFunction extends ServiceSupport implements
String returnValue = null;
String defaultValue = null;
String version = null;
- if (remainder.contains("/")) {
- String keyRemainder = StringHelper.before(remainder, "/");
+ if (remainder.contains("#")) {
+ String keyRemainder = StringHelper.before(remainder, "#");
engine = StringHelper.before(keyRemainder, ":");
key = StringHelper.after(keyRemainder, ":");
- subkey = StringHelper.after(remainder, "/");
+ subkey = StringHelper.after(remainder, "#");
defaultValue = StringHelper.after(subkey, ":");
if (ObjectHelper.isNotEmpty(defaultValue)) {
if (defaultValue.contains("@")) {
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 5dbcd03426f..75262b38e0a 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
@@ -66,7 +66,7 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
- from("direct:start").setBody(simple("{{hashicorp:secret:hello/id}}")).to("mock:bar");
+ from("direct:start").setBody(simple("{{hashicorp:secret:hello#id}}")).to("mock:bar");
}
});
context.start();
@@ -87,8 +87,8 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
- from("direct:username").setBody(simple("{{hashicorp:secret:hello/username}}")).to("mock:bar");
- from("direct:password").setBody(simple("{{hashicorp:secret: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();
@@ -374,7 +374,7 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello/id@1}}")).to("mock:bar");
+ from("direct:version").setBody(simple("{{hashicorp:secret:hello#id@1}}")).to("mock:bar");
}
});
context.start();
@@ -477,7 +477,7 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello/id:pippo@1}}"))
+ from("direct:version").setBody(simple("{{hashicorp:secret:hello#id:pippo@1}}"))
.to("mock:bar");
}
});
@@ -489,6 +489,27 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
MockEndpoint.assertIsSatisfied(context);
}
+ @Test
+ public void testPropertiesWithVersionFieldAndDefaultValueFunctionWithNotExistentVersion() throws Exception {
+ context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token"));
+ 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:secret:hello#id:pippo@2}}"))
+ .to("mock:bar");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:bar").expectedBodiesReceived("pippo");
+
+ template.sendBody("direct:version", "Hello World");
+ MockEndpoint.assertIsSatisfied(context);
+ }
+
@Test
public void testPropertiesWithDoubleEngines() throws Exception {
context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token"));
@@ -507,7 +528,7 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
});
context.start();
- getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}", "{id=22}");
+ getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}", "{id=21}");
template.sendBody("direct:engine1", "Hello World");
template.sendBody("direct:engine2", "Hello World");
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
deleted file mode 100644
index a85c929cd9d..00000000000
--- a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/HashicorpVaultPropertiesSourceTestIT.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.hashicorp.vault.integration;
-
-import org.apache.camel.FailedToCreateRouteException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
-
-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_HOST", matches = ".*")
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*")
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*")
- @Test
- public void testFunctio() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:start").setBody(simple("{{hashicorp:secret:hello}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21, password=password, username=admin}");
-
- template.sendBody("direct:start", "Hello World");
-
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testFunctionWithField() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:start").setBody(simple("{{hashicorp:secret:hello/id}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("21");
-
- template.sendBody("direct:start", "Hello World");
-
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "password");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexNoSubkeyPropertiesFunction() {
- Exception exception = assertThrows(FailedToCreateRouteException.class, () -> {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:username").setBody(simple("{{hashicorp:database_sample/not_existent}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin");
-
- template.sendBody("direct:username", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- });
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesDefaultValueFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesDefaultValueExceptionFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesExceptionFunction() {
- Exception exception = assertThrows(FailedToCreateRouteException.class, () -> {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- });
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexSimpleDefaultValueExceptionFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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", "pwd");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexSimpleNoDefaultValueExceptionFunction() {
- Exception exception = assertThrows(FailedToCreateRouteException.class, () -> {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:username").setBody(simple("{{hashicorp:secret:secretsuper}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin");
-
- template.sendBody("direct:username", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- });
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesNoDefaultValueFunction() {
- Exception exception = assertThrows(FailedToCreateRouteException.class, () -> {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- });
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesNotExistentDefaultValueFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:username").setBody(simple("{{hashicorp:secret:newsecret/additional1:admin}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin");
-
- template.sendBody("direct:username", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testComplexCustomPropertiesDefaultCredsDefaultValueFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:username").setBody(simple("{{hashicorp:secret:newsecret/additional1:admin}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("admin");
-
- template.sendBody("direct:username", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithDefaultFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("oscerd", "password");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithDefaultNotExistentFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- 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();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("oscerd", "password");
-
- template.sendBody("direct:username", "Hello World");
- template.sendBody("direct:password", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithVersionFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello/id@1}}")).to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("21");
-
- template.sendBody("direct:version", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithVersionAndNoFieldFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello@1}}")).to("mock:bar");
- }
- });
- context.start();
-
- 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_HOST", matches = ".*")
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*")
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*")
- @Test
- public void testPropertiesWithVersionNoFieldAndDefaultValueFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello:pippo@1}}"))
- .to("mock:bar");
- }
- });
- context.start();
-
- 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_HOST", matches = ".*")
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_PORT", matches = ".*")
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_SCHEME", matches = ".*")
- @Test
- public void testPropertiesWithVersionNoFieldDefaultValueNotExistentSecretFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello-3:pippo@4}}"))
- .to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("pippo");
-
- template.sendBody("direct:version", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithVersionNoFieldDefaultValueNotExistentVersionFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello:pippo@4}}"))
- .to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("pippo");
-
- template.sendBody("direct:version", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithVersionFieldAndDefaultValueFunction() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:version").setBody(simple("{{hashicorp:secret:hello/id:pippo@1}}"))
- .to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("21");
-
- template.sendBody("direct:version", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-
- @EnabledIfEnvironmentVariable(named = "CAMEL_HASHICORP_VAULT_TOKEN", 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 testPropertiesWithDoubleEngines() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:engine1").setBody(simple("{{hashicorp:secretengine1:hello}}"))
- .to("mock:bar");
-
- from("direct:engine2").setBody(simple("{{hashicorp:secretengine2:hello}}"))
- .to("mock:bar");
- }
- });
- context.start();
-
- getMockEndpoint("mock:bar").expectedBodiesReceived("{id=21}", "{id=22}");
-
- template.sendBody("direct:engine1", "Hello World");
- template.sendBody("direct:engine2", "Hello World");
- MockEndpoint.assertIsSatisfied(context);
- }
-}
(camel) 02/05: CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 24154bc3398eff74377cd1c919cdcef6c69fb087
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Sep 9 14:35:45 2024 +0200
CAMEL-21179 - Secret Properties Functions: Supporting secret name containing "/" - Hashicorp Vault
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../HashicorpVaultPropertiesSourceNoEnvTestIT.java | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
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 75262b38e0a..b1b1ae289f6 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
@@ -510,6 +510,27 @@ public class HashicorpVaultPropertiesSourceNoEnvTestIT extends CamelTestSupport
MockEndpoint.assertIsSatisfied(context);
}
+ @Test
+ public void testPropertiesWithVersionFieldAndDefaultValueWithSlashInName() throws Exception {
+ context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token"));
+ 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:secret:production/secrets/hello#id:pippo@1}}"))
+ .to("mock:bar");
+ }
+ });
+ context.start();
+
+ getMockEndpoint("mock:bar").expectedBodiesReceived("21");
+
+ template.sendBody("direct:version", "Hello World");
+ MockEndpoint.assertIsSatisfied(context);
+ }
+
@Test
public void testPropertiesWithDoubleEngines() throws Exception {
context.getVaultConfiguration().hashicorp().setToken(System.getProperty("camel.vault.hashicorp.token"));