-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0b7cb0
commit 0fc5276
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash -e | ||
|
||
# Run this script using summon | ||
# summon --provider summon-conjur ./e2e_test.sh | ||
|
||
REQUIRED_VARS=(AWS_REGION AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY) | ||
export AWS_BUCKET="summon-s3-ci" | ||
export AWS_ARTIFACT="ci-secret.txt" | ||
|
||
function main { | ||
check_required_vars | ||
build_summon_image | ||
test_output "test secret" | ||
} | ||
|
||
function check_required_vars { | ||
for var in "${REQUIRED_VARS[@]}"; do | ||
if [[ -z "${!var}" ]]; then | ||
echo "$var is not set" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
function build_summon_image { | ||
rm -rf summon | ||
git clone "https://github.com/cyberark/summon.git" | ||
pushd summon > /dev/null | ||
docker build . -t test-summon | ||
popd > /dev/null | ||
} | ||
|
||
# Helper function to build and run the Docker container | ||
function test_output { | ||
local expected_output="$1" | ||
local output=$(docker run --rm \ | ||
-v "$PWD:/summon-s3-src" -w "/summon-s3-src" \ | ||
-e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_BUCKET -e AWS_ARTIFACT \ | ||
test-summon \ | ||
go build > /dev/null && \ | ||
summon --provider ./pkg/darwin/summon-s3 \ | ||
--yaml "TEST_CRED: !var $AWS_BUCKET/$AWS_ARTIFACT" \ | ||
printenv TEST_CRED) || true | ||
|
||
if [ "$output" == "$expected_output" ] && [ $? -eq 0 ]; then | ||
echo "Test passed" | ||
exit 0 | ||
else | ||
echo "Test failed" | ||
echo "Expected output to equal: '$expected_output'. Actual output: $output" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
AWS_REGION: !var dev/aws/iam/users/sys_powerful/region | ||
AWS_ACCESS_KEY_ID: !var dev/aws/iam/users/sys_powerful/access_key_id | ||
AWS_SECRET_ACCESS_KEY: !var dev/aws/iam/users/sys_powerful/secret_access_key |