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:41 UTC
[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
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();
+ }
}