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/10/24 10:45:01 UTC

(camel) branch main updated: Camel AWS Secrets Manager - More property function tests with Localstack

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 a842accdcfc Camel AWS Secrets Manager - More property function tests with Localstack
a842accdcfc is described below

commit a842accdcfc05930e357f401d436a5bba35a85bc
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Oct 24 12:44:25 2024 +0200

    Camel AWS Secrets Manager - More property function tests with Localstack
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 ...etsManagerPropertiesSourceTestLocalstackIT.java | 40 ++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java
index 444af412e0e..4ae79a5779a 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestLocalstackIT.java
@@ -26,10 +26,21 @@ public class SecretsManagerPropertiesSourceTestLocalstackIT extends AwsSecretsMa
 
     @BeforeAll
     public static void setup() {
+        // Base secret
         CreateSecretRequest.Builder builder = CreateSecretRequest.builder();
         builder.name("test");
         builder.secretString("hello");
         getSecretManagerClient().createSecret(builder.build());
+
+        // Json multifield Secret
+        builder = CreateSecretRequest.builder();
+        builder.name("testJson");
+        builder.secretString("{\n" +
+                             "  \"username\": \"admin\",\n" +
+                             "  \"password\": \"password\",\n" +
+                             "  \"host\": \"myhost.com\"\n" +
+                             "}");
+        getSecretManagerClient().createSecret(builder.build());
     }
 
     @Test
@@ -42,15 +53,40 @@ public class SecretsManagerPropertiesSourceTestLocalstackIT extends AwsSecretsMa
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() {
-                from("direct:start").setBody(simple("{{aws:test}}")).to("mock:bar");
+                from("direct:start").setBody(simple("{{aws:test}}")).to("mock:result");
             }
         });
         context.start();
 
-        getMockEndpoint("mock:bar").expectedBodiesReceived("hello");
+        getMockEndpoint("mock:result").expectedBodiesReceived("hello");
 
         template.sendBody("direct:start", "Hello World");
 
         MockEndpoint.assertIsSatisfied(context);
     }
+
+    @Test
+    public void testFunctionJson() throws Exception {
+        context.getVaultConfiguration().aws().setAccessKey(getAccessKey());
+        context.getVaultConfiguration().aws().setSecretKey(getSecretKey());
+        context.getVaultConfiguration().aws().setRegion(getRegion());
+        context.getVaultConfiguration().aws().setOverrideEndpoint(true);
+        context.getVaultConfiguration().aws().setUriEndpointOverride(getUrlOverride());
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:username").setBody(simple("{{aws:testJson#username}}")).to("mock:bar");
+                from("direct:password").setBody(simple("{{aws:testJson#password}}")).to("mock:bar");
+                from("direct:host").setBody(simple("{{aws:testJson#host}}")).to("mock:bar");
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "password", "myhost.com");
+
+        template.sendBody("direct:username", "Hello World");
+        template.sendBody("direct:password", "Hello World");
+        template.sendBody("direct:host", "Hello World");
+        MockEndpoint.assertIsSatisfied(context);
+    }
 }