From 54193761711d73b981a7e10455c9670e1e399c44 Mon Sep 17 00:00:00 2001 From: Eric Berry Date: Tue, 3 Dec 2024 08:20:35 -0800 Subject: [PATCH] Testing additional tests --- .../tests/default_multivalue.fail.sh | 8 ++++++++ .../tests/default_multivalue.pass.sh | 8 ++++++++ .../tests/default_multivalue2.pass.sh | 8 ++++++++ .../tests/default_partial.fail.sh | 9 +++++++++ 4 files changed, 33 insertions(+) create mode 100644 linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.fail.sh create mode 100644 linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.pass.sh create mode 100644 linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue2.pass.sh create mode 100644 linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_partial.fail.sh diff --git a/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.fail.sh b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.fail.sh new file mode 100644 index 00000000000..6970170d33d --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.fail.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# variables = var_password_hashing_algorithm=good_value1|good_value2 + +if grep -q "^ENCRYPT_METHOD" /etc/login.defs; then + sed -i "s/^ENCRYPT_METHOD\b.*/ENCRYPT_METHOD wrong_value/" /etc/login.defs +else + echo "ENCRYPT_METHOD wrong_value" >> /etc/login.defs +fi diff --git a/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.pass.sh b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.pass.sh new file mode 100644 index 00000000000..741e6ecec62 --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue.pass.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# variables = var_password_hashing_algorithm=good_value1|good_value2 + +if grep -q "^ENCRYPT_METHOD" /etc/login.defs; then + sed -i "s/^ENCRYPT_METHOD\b.*/ENCRYPT_METHOD good_value2/" /etc/login.defs +else + echo "ENCRYPT_METHOD good_value2" >> /etc/login.defs +fi diff --git a/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue2.pass.sh b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue2.pass.sh new file mode 100644 index 00000000000..efdaf91799d --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_multivalue2.pass.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# variables = var_password_hashing_algorithm=good_value1|good_value2 + +if grep -q "^ENCRYPT_METHOD" /etc/login.defs; then + sed -i "s/^ENCRYPT_METHOD\b.*/ENCRYPT_METHOD good_value1/" /etc/login.defs +else + echo "ENCRYPT_METHOD good_value1" >> /etc/login.defs +fi diff --git a/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_partial.fail.sh b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_partial.fail.sh new file mode 100644 index 00000000000..707b7fe4bb9 --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_logindefs/tests/default_partial.fail.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# variables = var_password_hashing_algorithm=value1|value2 + +# test that partial match fails +if grep -q "^ENCRYPT_METHOD" /etc/login.defs; then + sed -i "s/^ENCRYPT_METHOD\b.*/ENCRYPT_METHOD value/" /etc/login.defs +else + echo "ENCRYPT_METHOD value" >> /etc/login.defs +fi