Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5FE55200CB9 for ; Sun, 2 Jul 2017 11:24:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 53CC3160BFE; Sun, 2 Jul 2017 09:24:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 24764160BD7 for ; Sun, 2 Jul 2017 11:24:08 +0200 (CEST) Received: (qmail 78528 invoked by uid 500); 2 Jul 2017 09:24:08 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 78519 invoked by uid 99); 2 Jul 2017 09:24:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jul 2017 09:24:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 72931E3AA7; Sun, 2 Jul 2017 09:24:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Sun, 02 Jul 2017 09:24:06 -0000 Message-Id: <9eaefe072a60409396b33cfec9194095@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] camel git commit: CAMEL-11491: Remove mandatory nature of Amazon Clients when accessKey and secretKey are provided archived-at: Sun, 02 Jul 2017 09:24:10 -0000 Repository: camel Updated Branches: refs/heads/camel-2.19.x 5fbdc0e61 -> ce5c96f0b refs/heads/master 36d6a6603 -> 73f1c78a3 CAMEL-11491: Remove mandatory nature of Amazon Clients when accessKey and secretKey are provided Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/73f1c78a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/73f1c78a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/73f1c78a Branch: refs/heads/master Commit: 73f1c78a3f442711e32001bd538fb8b6d12267c8 Parents: 36d6a66 Author: Thomas Demande Authored: Sun Jul 2 11:08:07 2017 +0200 Committer: Thomas Demande Committed: Sun Jul 2 11:08:07 2017 +0200 ---------------------------------------------------------------------- .../camel/component/aws/ddb/DdbComponent.java | 4 ++-- .../camel/component/aws/ec2/EC2Component.java | 6 +++--- .../camel/component/aws/sdb/SdbComponent.java | 4 ++-- .../camel/component/aws/ses/SesComponent.java | 4 ++-- .../camel/component/aws/sns/SnsComponent.java | 4 ++-- .../camel/component/aws/sqs/SqsComponent.java | 4 ++-- .../component/aws/ddb/DdbComponentTest.java | 6 +++++- .../aws/ec2/EC2ComponentConfigurationTest.java | 12 ++++++++++++ .../aws/sdb/SdbComponentConfigurationTest.java | 16 ++++++++++++++++ .../aws/ses/SesComponentConfigurationTest.java | 16 ++++++++++++++++ .../aws/sns/SnsComponentConfigurationTest.java | 15 +++++++++++++++ .../aws/sqs/SqsComponentConfigurationTest.java | 20 ++++++++++++++++++++ 12 files changed, 97 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java index 60707ba..156ff4d 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DdbComponent.java @@ -41,8 +41,8 @@ public class DdbComponent extends UriEndpointComponent { } configuration.setTableName(remaining); - if (configuration.getAmazonDDBClient() == null) { - throw new IllegalArgumentException("amazonDDBClient must be specified"); + if (configuration.getAmazonDDBClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("amazonDDBClient or accessKey and secretKey must be specified"); } DdbEndpoint endpoint = new DdbEndpoint(uri, this, configuration); http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Component.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Component.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Component.java index 545a297..693f382 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Component.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Component.java @@ -39,9 +39,9 @@ public class EC2Component extends UriEndpointComponent { protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { EC2Configuration configuration = new EC2Configuration(); setProperties(configuration, parameters); - - if (configuration.getAmazonEc2Client() == null) { - throw new IllegalArgumentException("amazonEC2Client must be specified"); + + if (configuration.getAmazonEc2Client() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("amazonEC2Client or accessKey and secretKey must be specified"); } EC2Endpoint endpoint = new EC2Endpoint(uri, this, configuration); http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbComponent.java index 989d35b..18c44d3 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbComponent.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/SdbComponent.java @@ -41,8 +41,8 @@ public class SdbComponent extends UriEndpointComponent { } configuration.setDomainName(remaining); - if (configuration.getAmazonSDBClient() == null) { - throw new IllegalArgumentException("amazonSDBClient must be specified"); + if (configuration.getAmazonSDBClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("amazonSDBClient or accessKey and secretKey must be specified"); } SdbEndpoint endpoint = new SdbEndpoint(uri, this, configuration); http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java index ba67145..d330533 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java @@ -41,8 +41,8 @@ public class SesComponent extends UriEndpointComponent { } configuration.setFrom(remaining); - if (configuration.getAmazonSESClient() == null) { - throw new IllegalArgumentException("AmazonSESClient must be specified"); + if (configuration.getAmazonSESClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("AmazonSESClient or accessKey and secretKey must be specified"); } return new SesEndpoint(uri, this, configuration); http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java index 1c270d4..da6b311 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java @@ -45,8 +45,8 @@ public class SnsComponent extends UriEndpointComponent { configuration.setTopicName(remaining); } - if (configuration.getAmazonSNSClient() == null) { - throw new IllegalArgumentException("AmazonSNSClient must be specified"); + if (configuration.getAmazonSNSClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("AmazonSNSClient or accessKey and secretKey must be specified"); } SnsEndpoint endpoint = new SnsEndpoint(uri, this, configuration); http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java index 4028d82..f865670 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java @@ -53,8 +53,8 @@ public class SqsComponent extends UriEndpointComponent { configuration.setQueueName(remaining); } - if (configuration.getAmazonSQSClient() == null) { - throw new IllegalArgumentException("AmazonSQSClient must be specified."); + if (configuration.getAmazonSQSClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("AmazonSQSClient or accessKey and secretKey must be specified."); } // Verify that visibilityTimeout is set if extendMessageVisibility is set to true. http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentTest.java index ad03469..8f91b29 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DdbComponentTest.java @@ -52,7 +52,11 @@ public class DdbComponentTest extends CamelTestSupport { } - + @Test + public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception { + DdbComponent component = new DdbComponent(context); + component.createEndpoint("aws-ddb://activeTable?accessKey=xxx&secretKey=yyy"); + } @Override protected JndiRegistry createRegistry() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ComponentConfigurationTest.java index 2dd3437..321de67 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ComponentConfigurationTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ComponentConfigurationTest.java @@ -37,6 +37,18 @@ public class EC2ComponentConfigurationTest extends CamelTestSupport { assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); assertNotNull(endpoint.getConfiguration().getAmazonEc2Client()); } + + + @Test + public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception { + EC2Component component = new EC2Component(context); + EC2Endpoint endpoint = (EC2Endpoint) component.createEndpoint( + "aws-ec2://TestDomain?accessKey=xxx&secretKey=yyy"); + + assertEquals("xxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); + assertNull(endpoint.getConfiguration().getAmazonEc2Client()); + } @Test(expected = IllegalArgumentException.class) public void createEndpointWithoutDomainName() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java index 8d4aa2b..93627e5 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java @@ -43,6 +43,22 @@ public class SdbComponentConfigurationTest extends CamelTestSupport { assertFalse(endpoint.getConfiguration().isConsistentRead()); assertNull(endpoint.getConfiguration().getMaxNumberOfDomains()); } + + @Test + public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception { + SdbComponent component = new SdbComponent(context); + SdbEndpoint endpoint = (SdbEndpoint) component.createEndpoint( + "aws-sdb://TestDomain?accessKey=xxx&secretKey=yyy"); + + assertEquals("TestDomain", endpoint.getConfiguration().getDomainName()); + assertEquals("xxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); + assertNull(endpoint.getConfiguration().getAmazonSDBClient()); + assertEquals(SdbOperations.PutAttributes, endpoint.getConfiguration().getOperation()); + assertNull(endpoint.getConfiguration().getAmazonSdbEndpoint()); + assertFalse(endpoint.getConfiguration().isConsistentRead()); + assertNull(endpoint.getConfiguration().getMaxNumberOfDomains()); + } @Test public void createEndpointWithMinimalConfigurationAndProvidedClient() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java index 1f86a50..8873a9c 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java @@ -43,6 +43,22 @@ public class SesComponentConfigurationTest extends CamelTestSupport { assertNull(endpoint.getConfiguration().getReturnPath()); assertNull(endpoint.getConfiguration().getReplyToAddresses()); } + + @Test + public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception { + SesComponent component = new SesComponent(context); + SesEndpoint endpoint = (SesEndpoint) component.createEndpoint("aws-ses://from@example.com?accessKey=xxx&secretKey=yyy"); + + assertEquals("from@example.com", endpoint.getConfiguration().getFrom()); + assertEquals("xxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); + assertNull(endpoint.getConfiguration().getAmazonSESEndpoint()); + assertNull(endpoint.getConfiguration().getAmazonSESClient()); + assertNull(endpoint.getConfiguration().getTo()); + assertNull(endpoint.getConfiguration().getSubject()); + assertNull(endpoint.getConfiguration().getReturnPath()); + assertNull(endpoint.getConfiguration().getReplyToAddresses()); + } @Test public void createEndpointWithMinimalConfigurationAndProvidedClient() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java index 3f8a3bc..65967da 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java @@ -40,7 +40,22 @@ public class SnsComponentConfigurationTest extends CamelTestSupport { assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint()); assertNull(endpoint.getConfiguration().getPolicy()); } + @Test + public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception { + SnsComponent component = new SnsComponent(context); + SnsEndpoint endpoint = (SnsEndpoint) component.createEndpoint("aws-sns://MyTopic?accessKey=xxx&secretKey=yyy"); + + assertEquals("MyTopic", endpoint.getConfiguration().getTopicName()); + assertEquals("xxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); + assertNull(endpoint.getConfiguration().getAmazonSNSClient()); + assertNull(endpoint.getConfiguration().getTopicArn()); + assertNull(endpoint.getConfiguration().getSubject()); + assertNull(endpoint.getConfiguration().getAmazonSNSEndpoint()); + assertNull(endpoint.getConfiguration().getPolicy()); + } + @Test public void createEndpointWithMinimalArnConfiguration() throws Exception { AmazonSNSClientMock mock = new AmazonSNSClientMock(); http://git-wip-us.apache.org/repos/asf/camel/blob/73f1c78a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java index 5bd717c..633d6e4 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java @@ -46,6 +46,26 @@ public class SqsComponentConfigurationTest extends CamelTestSupport { assertNull(endpoint.getConfiguration().getRedrivePolicy()); assertNull(endpoint.getConfiguration().getRegion()); } + @Test + public void createEndpointWithOnlyAccessKeyAndSecretKey() throws Exception { + SqsComponent component = new SqsComponent(context); + SqsEndpoint endpoint = (SqsEndpoint) component.createEndpoint("aws-sqs://MyQueue?accessKey=xxx&secretKey=yyy"); + + assertEquals("MyQueue", endpoint.getConfiguration().getQueueName()); + assertEquals("xxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); + assertNull(endpoint.getConfiguration().getAmazonSQSClient()); + assertNull(endpoint.getConfiguration().getAttributeNames()); + assertNull(endpoint.getConfiguration().getMessageAttributeNames()); + assertNull(endpoint.getConfiguration().getDefaultVisibilityTimeout()); + assertNull(endpoint.getConfiguration().getVisibilityTimeout()); + assertNull(endpoint.getConfiguration().getAmazonSQSEndpoint()); + assertNull(endpoint.getConfiguration().getMaximumMessageSize()); + assertNull(endpoint.getConfiguration().getMessageRetentionPeriod()); + assertNull(endpoint.getConfiguration().getPolicy()); + assertNull(endpoint.getConfiguration().getRedrivePolicy()); + assertNull(endpoint.getConfiguration().getRegion()); + } @Test public void createEndpointWithMinimalArnConfiguration() throws Exception {