From d2d5f3bd2e826a4ff4f0e93c22f7c485e1cb8a05 Mon Sep 17 00:00:00 2001 From: John ODonnell Date: Tue, 21 Dec 2021 21:29:19 -0500 Subject: [PATCH] Consolidate common files for Roles tests --- roles/conjur_host_identity/tests/test.sh | 8 +++-- .../tests => common}/test_default.py | 0 .../tests/test_default.py | 33 ------------------- 3 files changed, 5 insertions(+), 36 deletions(-) rename roles/conjur_host_identity/tests/test_cases/{configure-conjur-identity-from-collection/tests => common}/test_default.py (100%) delete mode 100644 roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/tests/test_default.py diff --git a/roles/conjur_host_identity/tests/test.sh b/roles/conjur_host_identity/tests/test.sh index 45d50c6d..70b54e5f 100755 --- a/roles/conjur_host_identity/tests/test.sh +++ b/roles/conjur_host_identity/tests/test.sh @@ -55,8 +55,10 @@ function setup_conjur { function run_test_cases { for test_case in test_cases/*; do - teardown_and_setup - run_test_case "$(basename -- "$test_case")" + if [ "${test_case}" != "test_cases/common" ]; then + teardown_and_setup + run_test_case "$(basename -- "$test_case")" + fi done } @@ -71,7 +73,7 @@ function run_test_case { " docker exec "${ansible_cid}" bash -ec " cd tests - py.test --junitxml=./junit/${test_case} --connection docker -v test_cases/${test_case}/tests/test_default.py + py.test --junitxml=./junit/${test_case} --connection docker -v test_cases/common/test_default.py " else echo ERROR: run_test called with no argument 1>&2 diff --git a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-collection/tests/test_default.py b/roles/conjur_host_identity/tests/test_cases/common/test_default.py similarity index 100% rename from roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-collection/tests/test_default.py rename to roles/conjur_host_identity/tests/test_cases/common/test_default.py diff --git a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/tests/test_default.py b/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/tests/test_default.py deleted file mode 100644 index 80513230..00000000 --- a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/tests/test_default.py +++ /dev/null @@ -1,33 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '/cyberark/tests/inventory.tmp').get_hosts('testapp') - - -def test_hosts_file(host): - f = host.file('/etc/hosts') - - assert f.exists - assert f.user == 'root' - assert f.group == 'root' - - -def test_is_conjurized(host): - identity_file = host.file('/etc/conjur.identity') - - assert identity_file.exists - assert identity_file.user == 'root' - - conf_file = host.file('/etc/conjur.conf') - - assert conf_file.exists - assert conf_file.user == 'root' - - -def test_retrieve_secret_with_summon(host): - result = host.check_output("summon --yaml 'DB_USERNAME: !var ansible/target-password' bash -c 'printenv DB_USERNAME'", shell=True) - - assert result == "target_secret_password"