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 2020/09/29 07:01:32 UTC

[camel] branch master updated (b12106c -> d925cda)

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 b12106c  Fix ASF Deploy gh action
     new 477ef96  Camel-AWS2-KMS: Added testcontainers and localstack for testing
     new d925cda  Camel-AWS2-KMS: Added localstack test for createKey operation

The 2 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:
 components/camel-aws2-kms/pom.xml                  | 70 ++++++++++++++++++++++
 .../aws2/kms/localstack/Aws2KmsBaseTest.java}      | 18 +++---
 .../localstack/KmsCreateKeyLocalstackTest.java}    | 26 ++++----
 3 files changed, 93 insertions(+), 21 deletions(-)
 copy components/{camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/Aws2EventbridgeBaseTest.java => camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/Aws2KmsBaseTest.java} (79%)
 copy components/{camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/localstack/S3MultipartUploadOperationLocalstackTest.java => camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/KmsCreateKeyLocalstackTest.java} (67%)


[camel] 01/02: Camel-AWS2-KMS: Added testcontainers and localstack for testing

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 477ef96069d794d69941cd6d85e2a531b3239842
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Sep 29 08:51:54 2020 +0200

    Camel-AWS2-KMS: Added testcontainers and localstack for testing
---
 components/camel-aws2-kms/pom.xml | 70 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/components/camel-aws2-kms/pom.xml b/components/camel-aws2-kms/pom.xml
index 4d2e267..b7032b7 100644
--- a/components/camel-aws2-kms/pom.xml
+++ b/components/camel-aws2-kms/pom.xml
@@ -67,5 +67,75 @@
             <artifactId>log4j-slf4j-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-testcontainers-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
+
+    <profiles>
+        <profile>
+            <id>aws2-s3-skip-tests</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>true</skipTests>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <!-- activate test if the docker socket file is accessible -->
+        <profile>
+            <id>aws2-s3-tests-docker-file</id>
+            <activation>
+                <file>
+                    <exists>/var/run/docker.sock</exists>
+                </file>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <!-- activate test if the DOCKER_HOST env var is set -->
+        <profile>
+            <id>aws2-s3-tests-docker-env</id>
+            <activation>
+                <property>
+                    <name>env.DOCKER_HOST</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>


[camel] 02/02: Camel-AWS2-KMS: Added localstack test for createKey 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 d925cdac2e2523084ea3155af525bd6f9223f592
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Sep 29 09:00:45 2020 +0200

    Camel-AWS2-KMS: Added localstack test for createKey operation
---
 .../aws2/kms/localstack/Aws2KmsBaseTest.java       | 76 ++++++++++++++++++++++
 .../kms/localstack/KmsCreateKeyLocalstackTest.java | 68 +++++++++++++++++++
 2 files changed, 144 insertions(+)

diff --git a/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/Aws2KmsBaseTest.java b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/Aws2KmsBaseTest.java
new file mode 100644
index 0000000..31d4c81
--- /dev/null
+++ b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/Aws2KmsBaseTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.aws2.kms.localstack;
+
+import java.net.URI;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.kms.KMS2Component;
+import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
+import org.apache.camel.test.testcontainers.junit5.Wait;
+import org.junit.jupiter.api.TestInstance;
+import org.testcontainers.containers.GenericContainer;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.kms.KmsClient;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class Aws2KmsBaseTest extends ContainerAwareTestSupport {
+
+    public static final String CONTAINER_IMAGE = "localstack/localstack:0.11.5";
+    public static final String CONTAINER_NAME = "eventbridge";
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return localstackContainer();
+    }
+
+    public static GenericContainer localstackContainer() {
+        return new GenericContainer(CONTAINER_IMAGE)
+                .withNetworkAliases(CONTAINER_NAME)
+                .withEnv("SERVICES", "kms")
+                .withExposedPorts(4566)
+                .waitingFor(Wait.forListeningPort())
+                .waitingFor(Wait.forLogMessageContaining("Ready.", 1));
+    }
+
+    public String getEventbridgeUrl() {
+        return String.format(
+                "%s:%d",
+                getContainerHost(CONTAINER_NAME),
+                getContainerPort(CONTAINER_NAME, 4566));
+    }
+
+    public KmsClient getKmsClient() {
+        KmsClient eventbridgeClient = KmsClient
+                .builder()
+                .endpointOverride(URI.create("http://" + getEventbridgeUrl()))
+                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
+                .region(Region.EU_WEST_1)
+                .build();
+        return eventbridgeClient;
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        KMS2Component kmsComponent = context.getComponent("aws2-kms", KMS2Component.class);
+        kmsComponent.getConfiguration().setKmsClient(getKmsClient());
+        return context;
+    }
+}
diff --git a/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/KmsCreateKeyLocalstackTest.java b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/KmsCreateKeyLocalstackTest.java
new file mode 100644
index 0000000..71da566
--- /dev/null
+++ b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/localstack/KmsCreateKeyLocalstackTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.aws2.kms.localstack;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws2.kms.KMS2Constants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.kms.model.CreateKeyResponse;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class KmsCreateKeyLocalstackTest extends Aws2KmsBaseTest {
+
+    @EndpointInject
+    private ProducerTemplate template;
+
+    @EndpointInject("mock:result")
+    private MockEndpoint result;
+
+    @Test
+    public void sendIn() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.send("direct:createKey", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(KMS2Constants.OPERATION, "createKey");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+        assertEquals(1, result.getExchanges().size());
+        assertNotNull(result.getExchanges().get(0).getIn().getBody(CreateKeyResponse.class).keyMetadata().keyId());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String awsEndpoint
+                        = "aws2-kms://default?operation=createKey";
+                from("direct:createKey").to(awsEndpoint).to("mock:result");
+            }
+        };
+    }
+}