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 a696cbe3e1b3d151d16eca5d343966103576a805 Author: Andrea Cosentino <[email protected]> AuthorDate: Wed Feb 23 10:55:38 2022 +0100 CAMEL-17700 - AWS Secret Manager Properties Source: Provide a fallback default value --- .../SecretsManagerNoEnvPropertiesSourceTestIT.java | 42 ++++++++++++++++++++++ .../SecretsManagerPropertiesSourceTestIT.java | 26 +++++++++++--- 2 files changed, 63 insertions(+), 5 deletions(-) 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 25320a3..ec8a32d 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 @@ -246,4 +246,46 @@ public class SecretsManagerNoEnvPropertiesSourceTestIT extends CamelTestSupport assertMockEndpointsSatisfied(); }); } + + @Test + public void testComplexCustomPropertiesNoDefaultValueFunction() 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")); + Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:username").setBody(simple("{{aws:postgresql/additional1}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{aws:postgresql/additional2}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret"); + + template.sendBody("direct:username", "Hello World"); + template.sendBody("direct:password", "Hello World"); + assertMockEndpointsSatisfied(); + }); + } + + @Test + public void testComplexCustomPropertiesNotExistentDefaultValueFunction() 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:newsecret/additional1:admin}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("admin"); + + template.sendBody("direct:username", "Hello World"); + assertMockEndpointsSatisfied(); + } } 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 47e646f..7e9158a 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 @@ -214,20 +214,36 @@ public class SecretsManagerPropertiesSourceTestIT extends CamelTestSupport { @Test public void testComplexCustomPropertiesNoDefaultValueFunction() throws Exception { Exception exception = assertThrows(FailedToCreateRouteException.class, () -> { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:username").setBody(simple("{{aws:postgresql/additional1}}")).to("mock:bar"); + from("direct:password").setBody(simple("{{aws:postgresql/additional2}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret"); + + template.sendBody("direct:username", "Hello World"); + template.sendBody("direct:password", "Hello World"); + assertMockEndpointsSatisfied(); + }); + } + + @Test + public void testComplexCustomPropertiesNotExistentDefaultValueFunction() throws Exception { context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:username").setBody(simple("{{aws:postgresql/additional1}}")).to("mock:bar"); - from("direct:password").setBody(simple("{{aws:postgresql/additional2}}")).to("mock:bar"); + from("direct:username").setBody(simple("{{aws:newsecret/additional1:admin}}")).to("mock:bar"); } }); context.start(); - getMockEndpoint("mock:bar").expectedBodiesReceived("admin", "secret"); + getMockEndpoint("mock:bar").expectedBodiesReceived("admin"); template.sendBody("direct:username", "Hello World"); - template.sendBody("direct:password", "Hello World"); assertMockEndpointsSatisfied(); - }); } }
