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/30 07:08:18 UTC

[camel] branch sts-localstack created (now db42cf1)

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

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


      at db42cf1  Camel-AWS2-STS: Fixed typo in test name

This branch includes the following new commits:

     new 0a02741  Camel-AWS2-STS: Added testcontainers support in POM
     new 6ed49a6  Camel-AWS2-STS: Added localstack test for getSessionToken operation
     new 7e91b63  Camel-AWS2-STS: Localstack test fixed for getSessionToken
     new 8045e56  Camel-AWS2-STS: Added localstack test for getFederationToken operation
     new db42cf1  Camel-AWS2-STS: Fixed typo in test name

The 5 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.



[camel] 01/05: Camel-AWS2-STS: Added testcontainers support in POM

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

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

commit 0a02741c03e4c25d5941e52969a3a70b884f8117
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 30 08:50:07 2020 +0200

    Camel-AWS2-STS: Added testcontainers support in POM
---
 components/camel-aws2-sts/pom.xml | 70 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/components/camel-aws2-sts/pom.xml b/components/camel-aws2-sts/pom.xml
index 7a0bff0..2807d2c 100644
--- a/components/camel-aws2-sts/pom.xml
+++ b/components/camel-aws2-sts/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-sts-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-sts-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-sts-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] 03/05: Camel-AWS2-STS: Localstack test fixed for getSessionToken

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

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

commit 7e91b6329b68d81cd467656b8103562ca56c6cfa
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 30 09:00:41 2020 +0200

    Camel-AWS2-STS: Localstack test fixed for getSessionToken
---
 .../apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java    | 2 +-
 .../aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java          | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java
index 9d85c25..f350ce1 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java
@@ -57,7 +57,7 @@ public class Aws2StsBaseTest extends ContainerAwareTestSupport {
     }
 
     public StsClient getStsClient() {
-    	StsClient stsClient = StsClient
+        StsClient stsClient = StsClient
                 .builder()
                 .endpointOverride(URI.create("http://" + getEventbridgeUrl()))
                 .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java
index 7190615..f65c36d 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java
@@ -24,7 +24,6 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws2.sts.STS2Constants;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
-
 import software.amazon.awssdk.services.sts.model.GetSessionTokenResponse;
 
 import static org.junit.Assert.assertEquals;
@@ -42,7 +41,7 @@ public class StsGetSessionTokenLocalstackTest extends Aws2StsBaseTest {
     public void sendIn() throws Exception {
         result.expectedMessageCount(1);
 
-        template.send("direct:createKey", new Processor() {
+        template.send("direct:getSessonToken", new Processor() {
 
             @Override
             public void process(Exchange exchange) throws Exception {


[camel] 02/05: Camel-AWS2-STS: Added localstack test for getSessionToken operation

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

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

commit 6ed49a6fc04fefae931d007b4d602e4a73003a88
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 30 08:57:39 2020 +0200

    Camel-AWS2-STS: Added localstack test for getSessionToken operation
---
 .../aws2/sts/localstack/Aws2StsBaseTest.java       | 76 ++++++++++++++++++++++
 .../StsGetSessionTokenLocalstackTest.java          | 69 ++++++++++++++++++++
 2 files changed, 145 insertions(+)

diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.java
new file mode 100644
index 0000000..9d85c25
--- /dev/null
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/Aws2StsBaseTest.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.sts.localstack;
+
+import java.net.URI;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.sts.STS2Component;
+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.sts.StsClient;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class Aws2StsBaseTest extends ContainerAwareTestSupport {
+
+    public static final String CONTAINER_IMAGE = "localstack/localstack:0.11.5";
+    public static final String CONTAINER_NAME = "sts";
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return localstackContainer();
+    }
+
+    public static GenericContainer localstackContainer() {
+        return new GenericContainer(CONTAINER_IMAGE)
+                .withNetworkAliases(CONTAINER_NAME)
+                .withEnv("SERVICES", "sts")
+                .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 StsClient getStsClient() {
+    	StsClient stsClient = StsClient
+                .builder()
+                .endpointOverride(URI.create("http://" + getEventbridgeUrl()))
+                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
+                .region(Region.EU_WEST_1)
+                .build();
+        return stsClient;
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        STS2Component stsComponent = context.getComponent("aws2-sts", STS2Component.class);
+        stsComponent.getConfiguration().setStsClient(getStsClient());
+        return context;
+    }
+}
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java
new file mode 100644
index 0000000..7190615
--- /dev/null
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetSessionTokenLocalstackTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.sts.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.sts.STS2Constants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import software.amazon.awssdk.services.sts.model.GetSessionTokenResponse;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class StsGetSessionTokenLocalstackTest extends Aws2StsBaseTest {
+
+    @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(STS2Constants.OPERATION, "getSessionToken");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+        assertEquals(1, result.getExchanges().size());
+        assertNotNull(result.getExchanges().get(0).getIn().getBody(GetSessionTokenResponse.class).credentials().accessKeyId());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String awsEndpoint
+                        = "aws2-sts://default?operation=getSessionToken";
+                from("direct:getSessonToken").to(awsEndpoint).to("mock:result");
+            }
+        };
+    }
+}


[camel] 05/05: Camel-AWS2-STS: Fixed typo in test name

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

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

commit db42cf12b921b5df8a5db276d31439bd05c83e56
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 30 09:06:30 2020 +0200

    Camel-AWS2-STS: Fixed typo in test name
---
 ...okenLocalstackTest.java => StsGetFederationTokenLocalstackTest.java} | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederartionTokenLocalstackTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederationTokenLocalstackTest.java
similarity index 97%
rename from components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederartionTokenLocalstackTest.java
rename to components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederationTokenLocalstackTest.java
index 3d46440..1276bbb 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederartionTokenLocalstackTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederationTokenLocalstackTest.java
@@ -29,7 +29,7 @@ import software.amazon.awssdk.services.sts.model.GetFederationTokenResponse;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-public class StsGetFederartionTokenLocalstackTest extends Aws2StsBaseTest {
+public class StsGetFederationTokenLocalstackTest extends Aws2StsBaseTest {
 
     @EndpointInject
     private ProducerTemplate template;


[camel] 04/05: Camel-AWS2-STS: Added localstack test for getFederationToken operation

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

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

commit 8045e56c1ee2f11530332f270105382c6c42f6c3
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 30 09:06:00 2020 +0200

    Camel-AWS2-STS: Added localstack test for getFederationToken operation
---
 .../StsGetFederartionTokenLocalstackTest.java      | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederartionTokenLocalstackTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederartionTokenLocalstackTest.java
new file mode 100644
index 0000000..3d46440
--- /dev/null
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsGetFederartionTokenLocalstackTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.sts.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.sts.STS2Constants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.sts.model.GetFederationTokenResponse;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class StsGetFederartionTokenLocalstackTest extends Aws2StsBaseTest {
+
+    @EndpointInject
+    private ProducerTemplate template;
+
+    @EndpointInject("mock:result")
+    private MockEndpoint result;
+
+    @Test
+    public void sendIn() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.send("direct:getFederationToken", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(STS2Constants.OPERATION, "getFederationToken");
+                exchange.getIn().setHeader(STS2Constants.FEDERATED_NAME, "test");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+        assertEquals(1, result.getExchanges().size());
+        assertNotNull(
+                result.getExchanges().get(0).getIn().getBody(GetFederationTokenResponse.class).credentials().accessKeyId());
+        assertEquals("000000000000:test",
+                result.getExchanges().get(0).getIn().getBody(GetFederationTokenResponse.class).federatedUser()
+                        .federatedUserId());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String awsEndpoint
+                        = "aws2-sts://default?operation=getFederationToken";
+                from("direct:getFederationToken").to(awsEndpoint).to("mock:result");
+            }
+        };
+    }
+}