diff --git a/ci/test.sh b/ci/test.sh index 5beea6647..cba733412 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -ex -cd "${PWD}/tests/$@" +cd "${PWD}/tests/${1}" ./test.sh diff --git a/tests/conjur-host-identity/test.sh b/tests/conjur-host-identity/test.sh index ee2f4bcbb..b1fe9abd1 100755 --- a/tests/conjur-host-identity/test.sh +++ b/tests/conjur-host-identity/test.sh @@ -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='' @@ -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 { @@ -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 } @@ -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 " @@ -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 ' diff --git a/tests/conjur-host-identity/test_cases/configure-conjur-identity/tests/test_default.py b/tests/conjur-host-identity/test_cases/configure-conjur-identity/tests/test_default.py index 18402b6c6..245c17115 100644 --- a/tests/conjur-host-identity/test_cases/configure-conjur-identity/tests/test_default.py +++ b/tests/conjur-host-identity/test_cases/configure-conjur-identity/tests/test_default.py @@ -1,8 +1,12 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( '/conjurinc/tests/inventory.tmp').get_hosts('testapp') + def test_hosts_file(host): f = host.file('/etc/hosts')