From dc6219236dcdce1034fb1b4c41eb26dc9e8e4533 Mon Sep 17 00:00:00 2001 From: Manuel Reis Date: Tue, 13 Aug 2024 09:19:06 +0200 Subject: [PATCH] Address PR#2969 suggestions --- unit_test/.aws/config | 15 --------------- unit_test/.aws/credentials | 8 -------- unit_test/CMakeLists.txt | 2 +- unit_test/Makefile.am | 2 ++ unit_test/run_aws_config.sh | 34 ++++++++++++++++++++++++++++++---- 5 files changed, 33 insertions(+), 28 deletions(-) delete mode 100644 unit_test/.aws/config delete mode 100644 unit_test/.aws/credentials diff --git a/unit_test/.aws/config b/unit_test/.aws/config deleted file mode 100644 index a7084bb840..0000000000 --- a/unit_test/.aws/config +++ /dev/null @@ -1,15 +0,0 @@ -[uni] -region = somewhere-1 -endpoint_url = https://example.com/bucket/prefix/1 -key = value -extrakey = willbepropagated - -[profile unidata] -region = us-east-1 -endpoint_url = https://play.min.io/ -dummy_key = dummy_value - -[profile play] -region = us-east-1 -endpoint_url = https://play.min.io/ - diff --git a/unit_test/.aws/credentials b/unit_test/.aws/credentials deleted file mode 100644 index 2b955ab3ea..0000000000 --- a/unit_test/.aws/credentials +++ /dev/null @@ -1,8 +0,0 @@ -[play] -aws_access_key_id = DummyKeys -aws_secret_access_key = DummySecret - -[uni] -region = somewhere-2 -endpoint_url = https://example.com/bucket/prefix/2 -key = value2 diff --git a/unit_test/CMakeLists.txt b/unit_test/CMakeLists.txt index dfeb470ea3..39074424d8 100644 --- a/unit_test/CMakeLists.txt +++ b/unit_test/CMakeLists.txt @@ -47,5 +47,5 @@ ENDIF() add_bin_test(unit_test tst_exhash timer_utils.c) add_bin_test(unit_test tst_xcache timer_utils.c) -FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/\.aws) +FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE) diff --git a/unit_test/Makefile.am b/unit_test/Makefile.am index 7f29e12cba..6061edaf41 100644 --- a/unit_test/Makefile.am +++ b/unit_test/Makefile.am @@ -43,6 +43,8 @@ if NETCDF_ENABLE_S3_TESTALL check_PROGRAMS += test_s3sdk TESTS += run_s3sdk.sh endif +check_PROGRAMS += aws_config +TESTS += run_aws_config.sh endif EXTRA_DIST = CMakeLists.txt run_s3sdk.sh run_reclaim_tests.sh diff --git a/unit_test/run_aws_config.sh b/unit_test/run_aws_config.sh index 22af07406b..f5244b0ef2 100755 --- a/unit_test/run_aws_config.sh +++ b/unit_test/run_aws_config.sh @@ -12,17 +12,43 @@ isolate "testdir_ut_aws_config" THISDIR=`pwd` cd $ISOPATH +mkdir -p $THISDIR/.aws/ +echo """[uni] +region = somewhere-1 +endpoint_url = https://example.com/bucket/prefix/1 +key = value +extrakey = willbepropagated + +[profile unidata] +region = us-east-1 +endpoint_url = https://play.min.io/ +dummy_key = dummy_value + +[profile play] +region = us-east-1 +endpoint_url = https://play.min.io/""" > $THISDIR/.aws/config + + +echo """[play] +aws_access_key_id = DummyKeys +aws_secret_access_key = DummySecret + +[uni] +region = somewhere-2 +endpoint_url = https://example.com/bucket/prefix/2 +key = value2""" > $THISDIR/.aws/credentials + echo -e "Testing loading AWS configuration in ${THISDIR}/.aws/config" -env NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=unidata ${CMD} ${execdir}/aws_config endpoint_url region dummy_key +NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=unidata ${CMD} ${execdir}/aws_config endpoint_url region dummy_key echo "Status: $?" -env NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=play ${CMD} ${execdir}/aws_config endpoint_url region +NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=play ${CMD} ${execdir}/aws_config endpoint_url region echo "Status: $?" -env NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=uni ${CMD} ${execdir}/aws_config endpoint_url region key +NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=uni ${CMD} ${execdir}/aws_config endpoint_url region key echo "Status: $?" -env NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=uni ${CMD} ${execdir}/aws_config region=somewhere-2 endpoint_url=https://example.com/bucket/prefix/2 key=value2 extrakey=willbepropagated +NC_TEST_AWS_DIR=${THISDIR} AWS_PROFILE=uni ${CMD} ${execdir}/aws_config region=somewhere-2 endpoint_url=https://example.com/bucket/prefix/2 key=value2 extrakey=willbepropagated echo "Status: $?" echo ${CMD} ${execdir}/aws_config