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 09:37:28 UTC

[camel] branch assume-role-sts created (now 7148aa0)

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

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


      at 7148aa0  Camel-AWS2-STS: Added a localstack test for AssumeRole operation

This branch includes the following new commits:

     new 7148aa0  Camel-AWS2-STS: Added a localstack test for AssumeRole operation

The 1 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/01: Camel-AWS2-STS: Added a localstack test for AssumeRole operation

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

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

commit 7148aa0b976b34a1a010f830ffa9329d9b433077
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 30 11:36:38 2020 +0200

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

diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsAssumeRoleLocalstackTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsAssumeRoleLocalstackTest.java
new file mode 100644
index 0000000..2c23faf
--- /dev/null
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/localstack/StsAssumeRoleLocalstackTest.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.AssumeRoleResponse;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class StsAssumeRoleLocalstackTest extends Aws2StsBaseTest {
+
+    @EndpointInject
+    private ProducerTemplate template;
+
+    @EndpointInject("mock:result")
+    private MockEndpoint result;
+
+    @Test
+    public void sendIn() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.send("direct:assumeRole", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(STS2Constants.OPERATION, "assumeRole");
+                exchange.getIn().setHeader(STS2Constants.ROLE_SESSION_NAME, "user_test");
+                exchange.getIn().setHeader(STS2Constants.ROLE_ARN, "user_test");
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+        assertEquals(1, result.getExchanges().size());
+        assertNotNull(
+                result.getExchanges().get(0).getIn().getBody(AssumeRoleResponse.class).credentials().accessKeyId());
+        assertNotNull(
+                result.getExchanges().get(0).getIn().getBody(AssumeRoleResponse.class).assumedRoleUser().assumedRoleId());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String awsEndpoint
+                        = "aws2-sts://default?operation=assumeRole";
+                from("direct:assumeRole").to(awsEndpoint).to("mock:result");
+            }
+        };
+    }
+}