NIFI-2902 Fix for S3 Signer v4 Override This closes #1140.
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/b9a940bb Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/b9a940bb Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/b9a940bb Branch: refs/heads/appveyor-improvement Commit: b9a940bbd1c7afede946e2e7db948cc38582208f Parents: c883f98 Author: James Wing <jvw...@gmail.com> Authored: Sat Oct 15 12:49:15 2016 -0700 Committer: Pierre Villard <pierre.villard...@gmail.com> Committed: Mon Oct 17 22:51:45 2016 +0200 ---------------------------------------------------------------------- .../processors/aws/s3/AbstractS3Processor.java | 2 +- .../nifi/processors/aws/s3/TestPutS3Object.java | 64 ++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/b9a940bb/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java index 2f3fde8..b96c05e 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java @@ -121,7 +121,7 @@ public abstract class AbstractS3Processor extends AbstractAWSCredentialsProvider .required(false) .allowableValues( new AllowableValue("Default Signature", "Default Signature"), - new AllowableValue("AWSS3V4Signer", "Signature v4"), + new AllowableValue("AWSS3V4SignerType", "Signature v4"), new AllowableValue("S3SignerType", "Signature v2")) .defaultValue("Default Signature") .build(); http://git-wip-us.apache.org/repos/asf/nifi/blob/b9a940bb/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java new file mode 100644 index 0000000..00f4423 --- /dev/null +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestPutS3Object.java @@ -0,0 +1,64 @@ +/* + * 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.nifi.processors.aws.s3; + +import java.util.List; + +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; + +import com.amazonaws.ClientConfiguration; +import com.amazonaws.auth.AWSCredentialsProvider; +import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; +import com.amazonaws.services.s3.AmazonS3Client; + +import org.junit.Assert; +import org.junit.Test; + + +/** + * Unit tests for {@link PutS3Object}, without interaction with S3. + */ +public class TestPutS3Object { + + @Test + public void testSignerOverrideOptions() { + final AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); + final ClientConfiguration config = new ClientConfiguration(); + final PutS3Object processor = new PutS3Object(); + final TestRunner runner = TestRunners.newTestRunner(processor); + + final List<AllowableValue> allowableSignerValues = PutS3Object.SIGNER_OVERRIDE.getAllowableValues(); + final String defaultSignerValue = PutS3Object.SIGNER_OVERRIDE.getDefaultValue(); + + for (AllowableValue allowableSignerValue : allowableSignerValues) { + String signerType = allowableSignerValue.getValue(); + if (!signerType.equals(defaultSignerValue)) { + runner.setProperty(PutS3Object.SIGNER_OVERRIDE, signerType); + ProcessContext context = runner.getProcessContext(); + try { + AmazonS3Client s3Client = processor.createClient(context, credentialsProvider, config); + } catch (IllegalArgumentException argEx) { + Assert.fail(argEx.getMessage()); + } + } + } + } + +}