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/08/21 08:28:23 UTC
(camel) branch CAMEL-21101-4.4.x created (now 55e7f627174)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch CAMEL-21101-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
at 55e7f627174 CAMEL-21101 - Camel-Hashicorp-Vault: Get Secret operation doesn't take into account the secretPath configuration parameter
This branch includes the following new commits:
new 55e7f627174 CAMEL-21101 - Camel-Hashicorp-Vault: Get Secret operation doesn't take into account the secretPath configuration parameter
The 1 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.
(camel) 01/01: CAMEL-21101 - Camel-Hashicorp-Vault: Get Secret operation doesn't take into account the secretPath configuration parameter
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch CAMEL-21101-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 55e7f6271741cd34d61e2692e3c2685ba90dc83e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Aug 21 10:27:09 2024 +0200
CAMEL-21101 - Camel-Hashicorp-Vault: Get Secret operation doesn't take into account the secretPath configuration parameter
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../component/hashicorp/vault/HashicorpVaultProducer.java | 2 ++
.../operations/HashicorpProducerCreateSecretIT.java | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java
index 1be686a7544..571e5002334 100644
--- a/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java
+++ b/components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultProducer.java
@@ -65,6 +65,8 @@ public class HashicorpVaultProducer extends DefaultProducer {
String secretVersion = null;
if (ObjectHelper.isNotEmpty(exchange.getMessage().getHeader(HashicorpVaultConstants.SECRET_PATH))) {
secretPath = exchange.getMessage().getHeader(HashicorpVaultConstants.SECRET_PATH, String.class);
+ } else if (ObjectHelper.isNotEmpty(getEndpoint().getConfiguration().getSecretPath())) {
+ secretPath = getConfiguration().getSecretPath();
} else {
throw new IllegalArgumentException("Secret Path must be specified");
}
diff --git a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerCreateSecretIT.java b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerCreateSecretIT.java
index da1e1797d23..34d828b6bfc 100644
--- a/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerCreateSecretIT.java
+++ b/components/camel-hashicorp-vault/src/test/java/org/apache/camel/component/hashicorp/vault/integration/operations/HashicorpProducerCreateSecretIT.java
@@ -39,6 +39,9 @@ public class HashicorpProducerCreateSecretIT extends HashicorpVaultBase {
@EndpointInject("mock:result-read")
private MockEndpoint mockRead;
+ @EndpointInject("mock:result-read-with-param")
+ private MockEndpoint mockReadWithParam;
+
@Test
public void createSecretTest() throws InterruptedException {
@@ -58,11 +61,15 @@ public class HashicorpProducerCreateSecretIT extends HashicorpVaultBase {
exchange.getMessage().setHeader(HashicorpVaultConstants.SECRET_PATH, "test");
}
});
+ exchange = template.request("direct:readSecretWithPathParam", null);
MockEndpoint.assertIsSatisfied(context);
Exchange ret = mockRead.getExchanges().get(0);
assertNotNull(ret);
assertEquals("30", ((Map) ret.getMessage().getBody(Map.class).get("data")).get("integer"));
+ Exchange retWithParam = mockReadWithParam.getExchanges().get(0);
+ assertNotNull(retWithParam);
+ assertEquals("30", ((Map) retWithParam.getMessage().getBody(Map.class).get("data")).get("integer"));
}
@Override
@@ -79,6 +86,11 @@ public class HashicorpProducerCreateSecretIT extends HashicorpVaultBase {
.toF("hashicorp-vault://secret?operation=getSecret&token=RAW(%s)&host=%s&port=%s&scheme=http",
service.token(), service.host(), service.port())
.to("mock:result-read");
+
+ from("direct:readSecretWithPathParam")
+ .toF("hashicorp-vault://secret?operation=getSecret&token=RAW(%s)&host=%s&port=%s&scheme=http&secretPath=test",
+ service.token(), service.host(), service.port())
+ .to("mock:result-read-with-param");
}
};
}