From 58517d07bf00245d9a8b51a6ce7c323c63f733aa Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Dec 29 2023 23:47:50 +0000 Subject: Drop test_sudo We now test full highstates for each role, hence individual testing of the sudo states is no longer needed. The visudo configuration validation is taken care of by the check commands implemented in the sudoers formula states, which are executed as part of test_highstate. Signed-off-by: Georg Pfuetzenreuter --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1eaf765..db5a491 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -59,15 +59,6 @@ test_nginx: - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production -f nginx script: bin/test_nginx.sh -test_sudo: - extends: - - .test_common - before_script: - - bin/prepare_test_env.sh -g -s -n - - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production - script: bin/test_sudo.sh - - # Dynamically generated jobs prepare_includes: script: bin/render_gitlab_ci_includes.py -w diff --git a/bin/test_sudo.sh b/bin/test_sudo.sh deleted file mode 100755 index de93c8d..0000000 --- a/bin/test_sudo.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Validate the salt-generated sudo configs - -[[ $(whoami) == 'root' ]] || { echo 'Please run this script as root'; exit 1; } - -source bin/get_colors.sh - -reset_sudo() { - rm -rf /etc/sudoers* - cp -a /etc/orig/* /etc - printf "roles:\n- $role" > /etc/salt/grains -} - -mkdir /etc/orig -cp -a /etc/sudoers* /etc/orig - -run_tests() { - salt-call --local -l quiet state.apply sudoers,sudoers.included > /dev/null - visudo -c > output 2>&1 - STATUS=$? - if [[ $STATUS == 0 ]]; then - echo_PASSED - else - cat output - echo_FAILED - fi - echo - return $STATUS -} - -pushd pillar > /dev/null -SUDO_ROLES=( - # Get all the roles that contain sudoers entries - $(find role -type f -name '*.sls' -exec grep -l 'sudoers:' {} +) -) -popd > /dev/null - -ALL_STATUS=0 - -for _role in ${SUDO_ROLES[@]}; do - _role=${_role##*/} - role=${_role%%.*} - echo_INFO "Testing role: $role" - reset_sudo - run_tests || ALL_STATUS=$? -done - -exit $ALL_STATUS