Skip to content

Commit

Permalink
Fix sanity-test errors for Conjur Role
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyBoutcher committed Aug 19, 2020
1 parent 0cc0384 commit 6c03545
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -ex

cd "${PWD}/tests/$@"
cd "${PWD}/tests/${1}"

./test.sh
21 changes: 12 additions & 9 deletions tests/conjur-host-identity/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ trap finish EXIT
finish

# normalises project name by filtering non alphanumeric characters and transforming to lowercase
declare -x COMPOSE_PROJECT_NAME=$(echo ${BUILD_TAG:-"ansible-role-testing"} | sed -e 's/[^[:alnum:]]//g' | tr '[:upper:]' '[:lower:]')
declare -x COMPOSE_PROJECT_NAME
COMPOSE_PROJECT_NAME=$(echo "${BUILD_TAG:-ansible-plugin-testing}" | sed -e 's/[^[:alnum:]]//g' | tr '[:upper:]' '[:lower:]')

declare -x ANSIBLE_CONJUR_AUTHN_API_KEY=''
declare -x CLI_CONJUR_AUTHN_API_KEY=''
Expand All @@ -31,7 +32,9 @@ function api_key_for {
}

function hf_token {
echo $(docker exec ${cli_cid} conjur hostfactory tokens create --duration-days=5 ansible/ansible-factory | jq -r '.[0].token')
docker exec ${cli_cid} conjur hostfactory tokens create \
--duration-days=5 \
ansible/ansible-factory | jq -r '.[0].token'
}

function setup_conjur {
Expand All @@ -46,9 +49,9 @@ function setup_conjur {
}

function run_test_cases {
for test_case in `ls test_cases`; do
for test_case in $(ls test_cases); do
teardown_and_setup
run_test_case $test_case
run_test_case "${test_case}"
done
}

Expand All @@ -57,11 +60,11 @@ function run_test_case {
local test_case=$1
if [ ! -z "$test_case" ]
then
docker exec ${ansible_cid} env HFTOKEN=$(hf_token) bash -c "
docker exec "${ansible_cid}" env HFTOKEN="$(hf_token)" bash -c "
cd tests
ansible-playbook test_cases/${test_case}/playbook.yml
"
docker exec ${ansible_cid} bash -c "
docker exec "${ansible_cid}" bash -c "
cd tests
py.test --junitxml=./junit/${test_case} --connection docker -v test_cases/${test_case}/tests/test_default.py
"
Expand All @@ -77,10 +80,10 @@ function teardown_and_setup {
}

function wait_for_server {
docker exec ${cli_cid} bash -c '
docker exec "${cli_cid}" bash -c '
for i in $(seq 20); do
curl -o /dev/null -fs -X OPTIONS ${CONJUR_APPLIANCE_URL} > /dev/null && echo "server is up" && break
echo "."
curl -o /dev/null -fs -X OPTIONS '${CONJUR_APPLIANCE_URL}' > /dev/null && echo server is up && break
echo .
sleep 2
done
'
Expand Down
2 changes: 1 addition & 1 deletion tests/sanity/ignore-2.10.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Jenkinsfile shebang
tests/conjur/test.sh shebang
tests/conjur-host-identity/test.sh shebang
tests/conjur-host-identity/test.sh shebang
tests/conjur/policy/root.yml yamllint:unparsable-with-libyaml
tests/conjur-host-identity/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by summon utility (in Jenkinsfile), not via Python
ci/build_release shebang
Expand Down

0 comments on commit 6c03545

Please sign in to comment.