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 75931ae8fb0 CAMEL-18208 - vault: allow to retrieve a specific secret version/revision - AWS Secret Manager 75931ae8fb0 is described below commit 75931ae8fb03ccf593e9a98a2404fd8f35727d0a Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Tue Jul 12 07:59:10 2022 +0200 CAMEL-18208 - vault: allow to retrieve a specific secret version/revision - AWS Secret Manager --- .../SecretsManagerNoEnvPropertiesSourceTestIT.java | 119 +++++++++++++++++++++ 1 file changed, 119 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 216488502dc..a4abcf10ab2 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; @@ -330,4 +331,122 @@ public class SecretsManagerNoEnvPropertiesSourceTestIT extends CamelTestSupport template.sendBody("direct:password", "Hello World"); assertMockEndpointsSatisfied(); } + + @Test + public void testPropertiesWithVersionFunction() 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() { + from("direct:version").setBody(simple("{{aws:test/id@e8d0e680-a504-4b70-a9b2-acf5efe0ba23}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("27"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @Test + public void testPropertiesWithVersionAndNoFieldFunction() 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() { + from("direct:version").setBody(simple("{{aws:test@e8d0e680-a504-4b70-a9b2-acf5efe0ba23}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("{\"id\":\"27\"}"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @Test + public void testPropertiesWithVersionNoFieldAndDefaultValueFunction() 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() { + from("direct:version").setBody(simple("{{aws:test:pippo@e8d0e680-a504-4b70-a9b2-acf5efe0ba23}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("{\"id\":\"27\"}"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @Test + public void testPropertiesWithVersionNoFieldDefaultValueNotExistentSecretFunction() 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() { + from("direct:version").setBody(simple("{{aws:test1:pippo@e8d0e680-a504-4b70-a9b2-acf5efe0ba23}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("pippo"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @Test + public void testPropertiesWithVersionNoFieldDefaultValueNotExistentVersionFunction() 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() { + from("direct:version").setBody(simple("{{aws:test1:pippo@e8d0e680-a504-4b70-a9b2-acf5efe0ba29}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("pippo"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @Test + public void testPropertiesWithVersionFieldAndDefaultValueFunction() 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() { + from("direct:version").setBody(simple("{{aws:test/id:pippo@e8d0e680-a504-4b70-a9b2-acf5efe0ba23}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("27"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } }