hunyadi-dev commented on a change in pull request #970: URL: https://github.com/apache/nifi-minifi-cpp/pull/970#discussion_r552726196
########## File path: libminifi/test/aws-tests/FetchS3ObjectTests.cpp ########## @@ -0,0 +1,174 @@ +/** + * + * 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. + */ + +#include <fstream> + +#include "S3TestsFixture.h" +#include "processors/FetchS3Object.h" + +class FetchS3ObjectTestsFixture : public S3TestsFixture<minifi::aws::processors::FetchS3Object> { + public: + FetchS3ObjectTestsFixture() { + auto putfile = plan->addProcessor( + "PutFile", + "PutFile", + core::Relationship("success", "d"), + true); + char output_dir_mask[] = "/tmp/gt.XXXXXX"; + output_dir = test_controller.createTempDirectory(output_dir_mask); + plan->setProperty(putfile, "Directory", output_dir); + } + + std::string output_dir; +}; + +TEST_CASE_METHOD(FetchS3ObjectTestsFixture, "Test AWS credential setting", "[awsCredentials]") { + setBucket(); + + SECTION("Test property credentials") { + setAccesKeyCredentialsInProcessor(); + } + + SECTION("Test credentials setting from AWS Credentials service") { + setAccessKeyCredentialsInController(); + setCredentialsService(); + } + + SECTION("Test credentials file setting") { + setCredentialFile(s3_processor); + } + + SECTION("Test credentials file setting from AWS Credentials service") { + setCredentialFile(aws_credentials_service); + setCredentialsService(); + } + + SECTION("Test credentials setting using default credential chain") { + setUseDefaultCredentialsChain(s3_processor); + } + + SECTION("Test credentials setting from AWS Credentials service using default credential chain") { + setUseDefaultCredentialsChain(aws_credentials_service); + setCredentialsService(); + } + + test_controller.runSession(plan, true); + REQUIRE(mock_s3_wrapper_ptr->getCredentials().GetAWSAccessKeyId() == "key"); + REQUIRE(mock_s3_wrapper_ptr->getCredentials().GetAWSSecretKey() == "secret"); +} + +TEST_CASE_METHOD(FetchS3ObjectTestsFixture, "Test required property not set", "[awsS3Config]") { Review comment: :+1: for proper negative tests ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
