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 40fa54a9aa877935fd7421666053113e79fd9f71
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Jul 12 14:12:10 2022 +0200

    CAMEL-18208 - vault: allow to retrieve a specific secret version/revision - 
Google Secret Manager
---
 ...leSecretManagerPropertiesNoEnvSourceTestIT.java | 113 +++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git 
a/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesNoEnvSourceTestIT.java
 
b/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesNoEnvSourceTestIT.java
index 95cb291b095..7d05afcae54 100644
--- 
a/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesNoEnvSourceTestIT.java
+++ 
b/components/camel-google/camel-google-secret-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerPropertiesNoEnvSourceTestIT.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;
 
@@ -195,4 +196,116 @@ public class 
GoogleSecretManagerPropertiesNoEnvSourceTestIT extends CamelTestSup
         template.sendBody("direct:password", "Hello World");
         assertMockEndpointsSatisfied();
     }
+
+    @Test
+    public void testPropertiesWithVersionFunction() throws Exception {
+        
context.getVaultConfiguration().gcp().setServiceAccountKey(System.getProperty("camel.vault.gcp.serviceAccountKey"));
+        
context.getVaultConfiguration().gcp().setProjectId(System.getProperty("camel.vault.gcp.projectId"));
+        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();
+    }
+
+    @Test
+    public void testPropertiesWithVersionAndNoFieldFunction() throws Exception 
{
+        
context.getVaultConfiguration().gcp().setServiceAccountKey(System.getProperty("camel.vault.gcp.serviceAccountKey"));
+        
context.getVaultConfiguration().gcp().setProjectId(System.getProperty("camel.vault.gcp.projectId"));
+        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();
+    }
+
+    @Test
+    public void testPropertiesWithVersionNoFieldAndDefaultValueFunction() 
throws Exception {
+        
context.getVaultConfiguration().gcp().setServiceAccountKey(System.getProperty("camel.vault.gcp.serviceAccountKey"));
+        
context.getVaultConfiguration().gcp().setProjectId(System.getProperty("camel.vault.gcp.projectId"));
+        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();
+    }
+
+    @Test
+    public void 
testPropertiesWithVersionNoFieldDefaultValueNotExistentSecretFunction() throws 
Exception {
+        
context.getVaultConfiguration().gcp().setServiceAccountKey(System.getProperty("camel.vault.gcp.serviceAccountKey"));
+        
context.getVaultConfiguration().gcp().setProjectId(System.getProperty("camel.vault.gcp.projectId"));
+        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();
+    }
+
+    @Test
+    public void 
testPropertiesWithVersionNoFieldDefaultValueNotExistentVersionFunction() throws 
Exception {
+        
context.getVaultConfiguration().gcp().setServiceAccountKey(System.getProperty("camel.vault.gcp.serviceAccountKey"));
+        
context.getVaultConfiguration().gcp().setProjectId(System.getProperty("camel.vault.gcp.projectId"));
+        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();
+    }
+
+    @Test
+    public void testPropertiesWithVersionFieldAndDefaultValueFunction() throws 
Exception {
+        
context.getVaultConfiguration().gcp().setServiceAccountKey(System.getProperty("camel.vault.gcp.serviceAccountKey"));
+        
context.getVaultConfiguration().gcp().setProjectId(System.getProperty("camel.vault.gcp.projectId"));
+        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();
+    }
 }

Reply via email to