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 05310ca8c83e515063fff3ac00467c6368efddd4 Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Jul 12 14:10:48 2022 +0200 CAMEL-18208 - vault: allow to retrieve a specific secret version/revision - Google Secret Manager --- .../GoogleSecretManagerPropertiesSourceTestIT.java | 115 ++++++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesSourceTestIT.java b/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesSourceTestIT.java index 391cf05eeeb..e7a7a7ce54f 100644 --- a/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesSourceTestIT.java +++ b/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesSourceTestIT.java @@ -188,9 +188,8 @@ public class GoogleSecretManagerPropertiesSourceTestIT extends CamelTestSupport assertMockEndpointsSatisfied(); } - @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_USE_DEFAULT_INSTANCE", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") - @EnabledIfEnvironmentVariable(named = "GOOGLE_APPLICATION_CREDENTIALS", matches = ".*") @Test public void testComplexPropertiesDefaultInstanceFunction() throws Exception { context.addRoutes(new RouteBuilder() { @@ -208,4 +207,116 @@ public class GoogleSecretManagerPropertiesSourceTestIT extends CamelTestSupport template.sendBody("direct:password", "Hello World"); assertMockEndpointsSatisfied(); } + + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") + @Test + public void testPropertiesWithVersionFunction() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:version").setBody(simple("{{gcp:hello@1}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("\"id\":\"23\""); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") + @Test + public void testPropertiesWithVersionAndNoFieldFunction() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:version").setBody(simple("{{gcp:hello}}")).to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("{\"id\":\"23\"}"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") + @Test + public void testPropertiesWithVersionNoFieldAndDefaultValueFunction() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:version").setBody(simple("{{gcp:hello:pippo@2}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("hello"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") + @Test + public void testPropertiesWithVersionNoFieldDefaultValueNotExistentSecretFunction() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:version").setBody(simple("{{gcp:test1:pippo@e8d0e680-a504-4b70-a9b2-acf5efe0ba23}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("pippo"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") + @Test + public void testPropertiesWithVersionNoFieldDefaultValueNotExistentVersionFunction() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:version").setBody(simple("{{gcp:test1:pippo@e8d0e680-a504-4b70-a9b2-acf5efe0ba29}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("pippo"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } + + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY", matches = ".*") + @EnabledIfEnvironmentVariable(named = "CAMEL_VAULT_GCP_PROJECT_ID", matches = ".*") + @Test + public void testPropertiesWithVersionFieldAndDefaultValueFunction() throws Exception { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("direct:version").setBody(simple("{{gcp:hello/id@3}}")) + .to("mock:bar"); + } + }); + context.start(); + + getMockEndpoint("mock:bar").expectedBodiesReceived("23"); + + template.sendBody("direct:version", "Hello World"); + assertMockEndpointsSatisfied(); + } }
