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/02/22 10:54:20 UTC

[camel] branch main updated (a0e9de1 -> 13e5d1e)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from a0e9de1  CAMEL-17691 - Camel Google Secret Manager: Add more operations - deleteSecret
     new 370ff09  CAMEL-17691 - Camel Google Secret Manager: Add more operations - listSecrets
     new abf1f15  CAMEL-17691 - Camel Google Secret Manager: Add more operations - fixed CS
     new 13e5d1e  CAMEL-17691 - Camel Google Secret Manager: Add more operations - fixed CS

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../manager/GoogleSecretManagerOperations.java     |  3 ++-
 .../manager/GoogleSecretManagerProducer.java       | 30 +++++++++++++++++++++-
 .../manager/integration/GoogleSecretManagerIT.java | 26 +++++++++++++++++++
 .../unit/GoogleSecretManagerConfigurationTest.java | 16 ++++++++++++
 4 files changed, 73 insertions(+), 2 deletions(-)

[camel] 01/03: CAMEL-17691 - Camel Google Secret Manager: Add more operations - listSecrets

Posted by ac...@apache.org.
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 370ff09855dc12e026c81efa538eaa960ab50a4c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Feb 22 11:49:09 2022 +0100

    CAMEL-17691 - Camel Google Secret Manager: Add more operations - listSecrets
---
 .../manager/GoogleSecretManagerOperations.java     |  3 ++-
 .../manager/GoogleSecretManagerProducer.java       | 16 +++++++++++++
 .../manager/integration/GoogleSecretManagerIT.java | 26 ++++++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerOperations.java b/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerOperations.java
index 1ed549c..790fa45 100644
--- a/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerOperations.java
+++ b/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerOperations.java
@@ -20,5 +20,6 @@ public enum GoogleSecretManagerOperations {
 
     createSecret,
     getSecretVersion,
-    deleteSecret;
+    deleteSecret,
+    listSecrets;
 }
diff --git a/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java b/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java
index 9bc631e..97d5e28 100644
--- a/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java
+++ b/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java
@@ -50,6 +50,9 @@ public class GoogleSecretManagerProducer extends DefaultProducer {
             case deleteSecret:
                 deleteSecret(endpoint.getClient(), exchange);
                 break;
+            case listSecrets:
+                listSecrets(endpoint.getClient(), exchange);
+                break;
             default:
                 throw new IllegalArgumentException("Unsupported operation");
         }
@@ -107,6 +110,19 @@ public class GoogleSecretManagerProducer extends DefaultProducer {
         }
     }
 
+    private void listSecrets(SecretManagerServiceClient client, Exchange exchange) throws InvalidPayloadException {
+        SecretManagerServiceClient.ListSecretsPagedResponse response;
+        if (getConfiguration().isPojoRequest()) {
+            ListSecretsRequest request = exchange.getIn().getMandatoryBody(ListSecretsRequest.class);
+            response = client.listSecrets(request);
+        } else {
+            String projectId = getConfiguration().getProject();
+            response = client.listSecrets(ProjectName.of(projectId));
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(response);
+    }
+
     private GoogleSecretManagerOperations determineOperation(Exchange exchange) {
         GoogleSecretManagerOperations operation = exchange.getIn().getHeader(GoogleSecretManagerConstants.OPERATION,
                 GoogleSecretManagerOperations.class);
diff --git a/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerIT.java b/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerIT.java
index 99774db..56e5276 100644
--- a/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerIT.java
+++ b/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/integration/GoogleSecretManagerIT.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.google.secret.manager.integration;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -42,6 +45,8 @@ public class GoogleSecretManagerIT extends CamelTestSupport {
     private MockEndpoint mockGetSecret;
     @EndpointInject("mock:deleteSecret")
     private MockEndpoint mockDeleteSecret;
+    @EndpointInject("mock:listSecrets")
+    private MockEndpoint listSecrets;
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -58,6 +63,10 @@ public class GoogleSecretManagerIT extends CamelTestSupport {
                                                    + serviceAccountKeyFile + "&operation=getSecretVersion")
                         .to("mock:getSecret");
 
+                from("direct:listSecrets").to("google-secret-manager://" + project + "?serviceAccountKey="
+                                              + serviceAccountKeyFile + "&operation=listSecrets")
+                        .to("mock:listSecrets");
+
                 from("direct:deleteSecret").to("google-secret-manager://" + project + "?serviceAccountKey="
                                                + serviceAccountKeyFile + "&operation=deleteSecret")
                         .to("mock:deleteSecret");
@@ -100,6 +109,23 @@ public class GoogleSecretManagerIT extends CamelTestSupport {
 
         assertEquals("Hello", ex.getMessage().getBody());
 
+        ex = template.request("direct:listSecrets", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        SecretManagerServiceClient.ListSecretsPagedResponse response
+                = ex.getMessage().getBody(SecretManagerServiceClient.ListSecretsPagedResponse.class);
+        AtomicInteger totalSecret = new AtomicInteger();
+        response
+                .iterateAll()
+                .forEach(
+                        secret -> {
+                            totalSecret.getAndIncrement();
+                        });
+
+        assertEquals(1, totalSecret.get());
         ex = template.request("direct:deleteSecret", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {

[camel] 02/03: CAMEL-17691 - Camel Google Secret Manager: Add more operations - fixed CS

Posted by ac...@apache.org.
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 abf1f151751552f890855db1189806d50f6f64ea
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Feb 22 11:51:55 2022 +0100

    CAMEL-17691 - Camel Google Secret Manager: Add more operations - fixed CS
---
 .../unit/GoogleSecretManagerConfigurationTest.java       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/unit/GoogleSecretManagerConfigurationTest.java b/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/unit/GoogleSecretManagerConfigurationTest.java
index d57a2bc..8bb4cd7 100644
--- a/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/unit/GoogleSecretManagerConfigurationTest.java
+++ b/components/camel-google/camel-google-secrets-manager/src/test/java/org/apache/camel/component/google/secret/manager/unit/GoogleSecretManagerConfigurationTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.google.secret.manager.unit;
 
 import org.apache.camel.component.google.secret.manager.GoogleSecretManagerComponent;

[camel] 03/03: CAMEL-17691 - Camel Google Secret Manager: Add more operations - fixed CS

Posted by ac...@apache.org.
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 13e5d1ec69e13372fb12c4da9a61bc51244546ef
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Feb 22 11:52:12 2022 +0100

    CAMEL-17691 - Camel Google Secret Manager: Add more operations - fixed CS
---
 .../google/secret/manager/GoogleSecretManagerProducer.java | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java b/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java
index 97d5e28..f0d00d0 100644
--- a/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java
+++ b/components/camel-google/camel-google-secrets-manager/src/main/java/org/apache/camel/component/google/secret/manager/GoogleSecretManagerProducer.java
@@ -16,7 +16,19 @@
  */
 package org.apache.camel.component.google.secret.manager;
 
-import com.google.cloud.secretmanager.v1.*;
+import com.google.cloud.secretmanager.v1.AccessSecretVersionRequest;
+import com.google.cloud.secretmanager.v1.AccessSecretVersionResponse;
+import com.google.cloud.secretmanager.v1.AddSecretVersionRequest;
+import com.google.cloud.secretmanager.v1.DeleteSecretRequest;
+import com.google.cloud.secretmanager.v1.ListSecretsRequest;
+import com.google.cloud.secretmanager.v1.ProjectName;
+import com.google.cloud.secretmanager.v1.Replication;
+import com.google.cloud.secretmanager.v1.Secret;
+import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
+import com.google.cloud.secretmanager.v1.SecretName;
+import com.google.cloud.secretmanager.v1.SecretPayload;
+import com.google.cloud.secretmanager.v1.SecretVersion;
+import com.google.cloud.secretmanager.v1.SecretVersionName;
 import com.google.protobuf.ByteString;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;