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 2022/03/02 07:14:39 UTC

[camel] branch main updated (fdc36a2 -> be8a62d)

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 fdc36a2  Sync deps and regen
     new 65feb73  CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret
     new 2ce6563  CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret
     new be8a62d  CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret

The 3 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:
 .../SecretsManagerPropertiesFunction.java          |  3 ++
 .../SecretsManagerNoEnvPropertiesSourceTestIT.java | 42 ++++++++++++++++++++++
 .../SecretsManagerPropertiesSourceTestIT.java      | 42 ++++++++++++++++++++++
 3 files changed, 87 insertions(+)

[camel] 02/03: CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret

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 2ce6563c8162d627c0dfb6745e89192d74675418
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 2 08:12:50 2022 +0100

    CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret
---
 .../SecretsManagerNoEnvPropertiesSourceTestIT.java | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java
index ec8a32d..bfdd547 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java
@@ -20,6 +20,7 @@ import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
 import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
 import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
 
@@ -288,4 +289,46 @@ public class SecretsManagerNoEnvPropertiesSourceTestIT extends CamelTestSupport
         template.sendBody("direct:username", "Hello World");
         assertMockEndpointsSatisfied();
     }
+
+    @Test
+    public void testPropertiesWithDefaultFunction() throws Exception {
+        context.getVaultConfiguration().aws().setAccessKey(System.getProperty("camel.vault.aws.accessKey"));
+        context.getVaultConfiguration().aws().setSecretKey(System.getProperty("camel.vault.aws.secretKey"));
+        context.getVaultConfiguration().aws().setRegion(System.getProperty("camel.vault.aws.region"));
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:username").setBody(simple("{{aws:postgresql/username:oscerd}}")).to("mock:bar");
+                from("direct:password").setBody(simple("{{aws:postgresql/password:password}}")).to("mock:bar");
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:bar").expectedBodiesReceived("postgres", "secret");
+
+        template.sendBody("direct:username", "Hello World");
+        template.sendBody("direct:password", "Hello World");
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testPropertiesWithDefaultNotExistentFunction() throws Exception {
+        context.getVaultConfiguration().aws().setAccessKey(System.getProperty("camel.vault.aws.accessKey"));
+        context.getVaultConfiguration().aws().setSecretKey(System.getProperty("camel.vault.aws.secretKey"));
+        context.getVaultConfiguration().aws().setRegion(System.getProperty("camel.vault.aws.region"));
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:username").setBody(simple("{{aws:db_sample/username:oscerd}}")).to("mock:bar");
+                from("direct:password").setBody(simple("{{aws: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");
+        assertMockEndpointsSatisfied();
+    }
 }

[camel] 01/03: CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret

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 65feb73d830d6d4a3138b88184f215c0c843541d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 2 08:12:02 2022 +0100

    CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret
---
 .../SecretsManagerPropertiesFunction.java          |  3 ++
 .../SecretsManagerPropertiesSourceTestIT.java      | 42 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
index 124a554..a04ca59 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerPropertiesFunction.java
@@ -141,6 +141,9 @@ public class SecretsManagerPropertiesFunction extends ServiceSupport implements
             key = StringHelper.before(remainder, "/");
             subkey = StringHelper.after(remainder, "/");
             defaultValue = StringHelper.after(subkey, ":");
+            if (subkey.contains(":")) {
+                subkey = StringHelper.before(subkey, ":");
+            }
         } else if (remainder.contains(":")) {
             key = StringHelper.before(remainder, ":");
             defaultValue = StringHelper.after(remainder, ":");
diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestIT.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestIT.java
index b5a0870..6ffd9b9 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestIT.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerPropertiesSourceTestIT.java
@@ -297,4 +297,46 @@ public class SecretsManagerPropertiesSourceTestIT extends CamelTestSupport {
         template.sendBody("direct:username", "Hello World");
         assertMockEndpointsSatisfied();
     }
+
+    @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_AWS_ACCESS_KEY", matches = ".*")
+    @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_AWS_SECRET_KEY", matches = ".*")
+    @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_AWS_REGION", matches = ".*")
+    @Test
+    public void testPropertiesWithDefaultFunction() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:username").setBody(simple("{{aws:postgresql/username:oscerd}}")).to("mock:bar");
+                from("direct:password").setBody(simple("{{aws:postgresql/password:password}}")).to("mock:bar");
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:bar").expectedBodiesReceived("postgres", "secret");
+
+        template.sendBody("direct:username", "Hello World");
+        template.sendBody("direct:password", "Hello World");
+        assertMockEndpointsSatisfied();
+    }
+
+    @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_AWS_ACCESS_KEY", matches = ".*")
+    @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_AWS_SECRET_KEY", matches = ".*")
+    @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_AWS_REGION", matches = ".*")
+    @Test
+    public void testPropertiesWithDefaultNotExistentFunction() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:username").setBody(simple("{{aws:db_sample/username:oscerd}}")).to("mock:bar");
+                from("direct:password").setBody(simple("{{aws: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");
+        assertMockEndpointsSatisfied();
+    }
 }

[camel] 03/03: CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret

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 be8a62dbe5ade380caa57038364b2a346eff52cb
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 2 08:13:46 2022 +0100

    CAMEL-17730 - Camel-AWS Secret Manager Properties Source: if the subkey contains a default value the actual won't substitute correctly the secret
---
 .../integration/SecretsManagerNoEnvPropertiesSourceTestIT.java           | 1 -
 1 file changed, 1 deletion(-)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java
index bfdd547..94cc1d1 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerNoEnvPropertiesSourceTestIT.java
@@ -20,7 +20,6 @@ import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
 import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
 import org.junit.jupiter.api.condition.EnabledIfSystemProperty;