From c29986841828da0d9d4efd238108e5e65493488f Mon Sep 17 00:00:00 2001 From: Marcus Burghardt Date: Fri, 13 Sep 2024 11:23:51 +0200 Subject: [PATCH] Simplify and align logic in test scenarios Signed-off-by: Marcus Burghardt --- .../custom_conf_services_pam_missing.fail.sh | 13 +++++++------ .../tests/missing_sections.fail.sh | 9 ++++++--- .../tests/multiple_wrong_entries.fail.sh | 16 ++++++++-------- .../tests/services_pam_missing.fail.sh | 10 +++++----- .../tests/services_pam_wrong_section.fail.sh | 8 +++++--- .../tests/sssd_config_missing.fail.sh | 6 ++++-- .../tests/sssd_pam_services.pass.sh | 9 +++++---- .../tests/sssd_pam_services_conf_d.pass.sh | 11 +++++++---- 8 files changed, 47 insertions(+), 35 deletions(-) diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/custom_conf_services_pam_missing.fail.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/custom_conf_services_pam_missing.fail.sh index 98dd578bae56..e255caf21633 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/custom_conf_services_pam_missing.fail.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/custom_conf_services_pam_missing.fail.sh @@ -1,11 +1,12 @@ #!/bin/bash # packages = sssd-common -rm -rf /etc/sssd/conf.d/ -mkdir -p /etc/sssd/conf.d/ -SSSD_CONF="/etc/sssd/conf.d/sssd.conf" +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILE="/etc/sssd/conf.d/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" -cp wrong_sssd.conf $SSSD_CONF +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES -SSSD_CONF="/etc/sssd/sssd.conf" -cp wrong_sssd.conf $SSSD_CONF +for file in $SSSD_CONF_FILE $SSSD_CONF_DIR_FILE; do + cp wrong_sssd.conf $file +done diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/missing_sections.fail.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/missing_sections.fail.sh index 2240c45aaa15..0b7a7c033afb 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/missing_sections.fail.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/missing_sections.fail.sh @@ -1,7 +1,10 @@ #!/bin/bash # packages = sssd-common -rm /etc/sssd/sssd.conf -rm -rf /etc/sssd/conf.d/ +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" + +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES + # Only empty config without any section -touch /etc/sssd/sssd.conf +touch $SSSD_CONF_FILE diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/multiple_wrong_entries.fail.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/multiple_wrong_entries.fail.sh index 4ee2a97e5374..05db3904b932 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/multiple_wrong_entries.fail.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/multiple_wrong_entries.fail.sh @@ -1,17 +1,17 @@ #!/bin/bash # packages = sssd-common -rm -rf /etc/sssd/conf.d/ -mkdir -p /etc/sssd/conf.d/ -SSSD_CONF="/etc/sssd/conf.d/sssd.conf" +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILE="/etc/sssd/conf.d/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" -cp wrong_sssd.conf $SSSD_CONF +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES -SSSD_CONF="/etc/sssd/sssd.conf" -cp wrong_sssd.conf $SSSD_CONF +for file in $SSSD_CONF_FILE $SSSD_CONF_DIR_FILE; do + cp wrong_sssd.conf $file +done -SSSD_CONF="/etc/sssd/sssd_custom.conf" -cat < $SSSD_CONF +cat < "/etc/sssd/conf.d/sssd_custom.conf" [sssd] services = nss domains = shadowutils diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_missing.fail.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_missing.fail.sh index 901ac9074830..05c1dff77159 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_missing.fail.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_missing.fail.sh @@ -1,12 +1,12 @@ #!/bin/bash # packages = sssd-common -# -SSSD_CONF="/etc/sssd/sssd.conf" +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" -rm -rf /etc/sssd/conf.d/ -rm -f $SSSD_CONF -cat < $SSSD_CONF +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES + +cat < $SSSD_CONF_FILE [sssd] section1 = key section2 = nss diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_wrong_section.fail.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_wrong_section.fail.sh index 201b1c9d9234..8d50ef189e5f 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_wrong_section.fail.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/services_pam_wrong_section.fail.sh @@ -1,6 +1,8 @@ #!/bin/bash # packages = sssd-common -rm -rf /etc/sssd/conf.d/ -SSSD_CONF="/etc/sssd/sssd.conf" -cp wrong_sssd.conf $SSSD_CONF +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" + +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES +cp wrong_sssd.conf $SSSD_CONF_FILE diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_config_missing.fail.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_config_missing.fail.sh index 8cd9b81a0e7c..2c2a9a715b1f 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_config_missing.fail.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_config_missing.fail.sh @@ -2,5 +2,7 @@ # packages = sssd-common # remediation = none -rm /etc/sssd/sssd.conf -rm -rf /etc/sssd/conf.d/ +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" + +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services.pass.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services.pass.sh index 3fac47c8b1c3..e3bf6f5e6c27 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services.pass.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services.pass.sh @@ -1,11 +1,12 @@ #!/bin/bash # packages = sssd-common -SSSD_CONF="/etc/sssd/sssd.conf" +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" -rm -rf /etc/sssd/conf.d/ -rm -f SSSD_CONF -cat < $SSSD_CONF +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES + +cat < $SSSD_CONF_FILE [sssd] services = nss,pam [pam] diff --git a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services_conf_d.pass.sh b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services_conf_d.pass.sh index e3c1deb06d17..6868bb35fea2 100644 --- a/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services_conf_d.pass.sh +++ b/linux_os/guide/services/sssd/sssd_enable_pam_services/tests/sssd_pam_services_conf_d.pass.sh @@ -1,10 +1,13 @@ #!/bin/bash # packages = sssd-common -rm -rf "/etc/sssd/conf.d/" -rm -f "/etc/sssd/sssd.conf" -mkdir -p "/etc/sssd/conf.d/" -cat < "/etc/sssd/conf.d/sssd.conf" +SSSD_CONF_FILE="/etc/sssd/sssd.conf" +SSSD_CONF_DIR_FILE="/etc/sssd/conf.d/sssd.conf" +SSSD_CONF_DIR_FILES="/etc/sssd/conf.d/*.conf" + +rm -rf $SSSD_CONF_FILE $SSSD_CONF_DIR_FILES + +cat < $SSSD_CONF_DIR_FILE [sssd] services = nss,pam [pam]