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


The following commit(s) were added to refs/heads/main by this push:
     new 72f98fc43bd CAMEL-21101 - Camel-Hashicorp-Vault: Get Secret operation 
doesn't take into account the secretPath configuration parameter (#15246)
72f98fc43bd is described below

commit 72f98fc43bd2be18e0b9b8c7a47f504e66e77935
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Aug 21 10:49:44 2024 +0200

    CAMEL-21101 - Camel-Hashicorp-Vault: Get Secret operation doesn't take into 
account the secretPath configuration parameter (#15246)
    
    Signed-off-by: Andrea Cosentino <[email protected]>
---
 .../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");
             }
         };
     }

Reply via email to