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 2021/03/15 10:27:00 UTC

[camel] branch master updated (8c1177a -> 1dcf310)

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

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


    from 8c1177a  Fix management tests due to test refactoring
     new 5d1ddc3  CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation
     new 8fb506b  CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation
     new 1dcf310  CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation

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:
 .../aws/secretsmanager/SecretsManagerProducer.java | 78 ++++++++++------------
 1 file changed, 37 insertions(+), 41 deletions(-)


[camel] 01/03: CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5d1ddc37c326bc848f127e0d0bce303c1e95cfd4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Mar 15 11:24:54 2021 +0100

    CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation
---
 .../aws/secretsmanager/SecretsManagerProducer.java | 78 ++++++++++------------
 ...etsManagerGetSecretProducerIntegrationTest.java |  3 +-
 2 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerProducer.java b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerProducer.java
index ffffc3f..3bed29a 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerProducer.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsManagerProducer.java
@@ -70,8 +70,8 @@ public class SecretsManagerProducer extends DefaultProducer {
     }
 
     private SecretsManagerOperations determineOperation(Exchange exchange) {
-        SecretsManagerOperations operation
-                = exchange.getIn().getHeader(SecretsManagerConstants.OPERATION, SecretsManagerOperations.class);
+        SecretsManagerOperations operation = exchange.getIn().getHeader(SecretsManagerConstants.OPERATION,
+                SecretsManagerOperations.class);
         if (operation == null) {
             operation = getConfiguration().getOperation();
         }
@@ -85,8 +85,8 @@ public class SecretsManagerProducer extends DefaultProducer {
     @Override
     public String toString() {
         if (secretsManagerProducerToString == null) {
-            secretsManagerProducerToString
-                    = "SecretsManagerProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
+            secretsManagerProducerToString = "SecretsManagerProducer["
+                                             + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
         }
         return secretsManagerProducerToString;
     }
@@ -96,7 +96,8 @@ public class SecretsManagerProducer extends DefaultProducer {
         return (SecretsManagerEndpoint) super.getEndpoint();
     }
 
-    private void listSecrets(SecretsManagerClient secretsManagerClient, Exchange exchange) throws InvalidPayloadException {
+    private void listSecrets(SecretsManagerClient secretsManagerClient, Exchange exchange)
+            throws InvalidPayloadException {
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
             if (payload instanceof ListSecretsRequest) {
@@ -130,52 +131,47 @@ public class SecretsManagerProducer extends DefaultProducer {
         }
     }
 
-    private void createSecret(SecretsManagerClient secretsManagerClient, Exchange exchange) throws InvalidPayloadException {
+    private void createSecret(SecretsManagerClient secretsManagerClient, Exchange exchange)
+            throws InvalidPayloadException {
+        CreateSecretRequest request = null;
+        CreateSecretResponse result;
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
             if (payload instanceof CreateSecretRequest) {
-                CreateSecretResponse result;
-                try {
-                    CreateSecretRequest request = (CreateSecretRequest) payload;
-                    result = secretsManagerClient.createSecret(request);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("Create Secret command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
+                request = (CreateSecretRequest) payload;
             }
         } else {
             CreateSecretRequest.Builder builder = CreateSecretRequest.builder();
-            CreateSecretResponse result;
-            try {
-                String payload = exchange.getIn().getMandatoryBody(String.class);
-                if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(SecretsManagerConstants.SECRET_NAME))) {
-                    String secretName = exchange.getIn().getHeader(SecretsManagerConstants.SECRET_NAME, String.class);
-                    builder.name(secretName);
-                } else {
-                    throw new IllegalArgumentException("Secret Name must be specified");
-                }
-                if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(SecretsManagerConstants.SECRET_DESCRIPTION))) {
-                    String descr = exchange.getIn().getHeader(SecretsManagerConstants.SECRET_DESCRIPTION, String.class);
-                    builder.description(descr);
-                }
-                if (getConfiguration().isBinaryPayload()) {
-                    builder.secretBinary(SdkBytes.fromUtf8String(Base64.getEncoder().encodeToString(payload.getBytes())));
-                } else {
-                    builder.secretString((String) payload);
-                }
-                result = secretsManagerClient.createSecret(builder.build());
-            } catch (AwsServiceException ase) {
-                LOG.trace("Create Secret command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
+            String payload = exchange.getIn().getMandatoryBody(String.class);
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(SecretsManagerConstants.SECRET_NAME))) {
+                String secretName = exchange.getIn().getHeader(SecretsManagerConstants.SECRET_NAME, String.class);
+                builder.name(secretName);
+            } else {
+                throw new IllegalArgumentException("Secret Name must be specified");
             }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(SecretsManagerConstants.SECRET_DESCRIPTION))) {
+                String descr = exchange.getIn().getHeader(SecretsManagerConstants.SECRET_DESCRIPTION, String.class);
+                builder.description(descr);
+            }
+            if (getConfiguration().isBinaryPayload()) {
+                builder.secretBinary(SdkBytes.fromUtf8String(Base64.getEncoder().encodeToString(payload.getBytes())));
+            } else {
+                builder.secretString((String) payload);
+            }
+            request = builder.build();
+        }
+        try {
+            result = secretsManagerClient.createSecret(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("Create Secret command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
         }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
-    private void getSecret(SecretsManagerClient secretsManagerClient, Exchange exchange) throws InvalidPayloadException {
+    private void getSecret(SecretsManagerClient secretsManagerClient, Exchange exchange)
+            throws InvalidPayloadException {
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
             if (payload instanceof GetSecretValueRequest) {
diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
index e031c60..2744ef3 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
@@ -23,12 +23,11 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws.secretsmanager.SecretsManagerConstants;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-@Disabled("This test must be manually started, you need to specify AWS Credentials")
+//@Disabled("This test must be manually started, you need to specify AWS Credentials")
 public class SecretsManagerGetSecretProducerIntegrationTest extends CamelTestSupport {
 
     @EndpointInject("mock:result")


[camel] 03/03: CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1dcf3101f473669d3dafde0e44b72f56fec84e38
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Mar 15 11:25:54 2021 +0100

    CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation
---
 .../integration/SecretsManagerGetSecretProducerIntegrationTest.java      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
index 2c8a57b..e031c60 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws.secretsmanager.SecretsManagerConstants;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;


[camel] 02/03: CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8fb506b7abe4e60e509bd5c295bcfada28b6ba5e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Mar 15 11:25:21 2021 +0100

    CAMEL-16323 - Create a Camel-AWS-Secret-Manager component - getSecret operation
---
 .../integration/SecretsManagerGetSecretProducerIntegrationTest.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
index 2744ef3..2c8a57b 100644
--- a/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
+++ b/components/camel-aws/camel-aws-secrets-manager/src/test/java/org/apache/camel/component/aws/secretsmanager/integration/SecretsManagerGetSecretProducerIntegrationTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-//@Disabled("This test must be manually started, you need to specify AWS Credentials")
+@Disabled("This test must be manually started, you need to specify AWS Credentials")
 public class SecretsManagerGetSecretProducerIntegrationTest extends CamelTestSupport {
 
     @EndpointInject("mock:result")