From 7920d85ef806cda6a37db16aff75f895cc67a3e1 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sun, 25 Jun 2017 16:25:27 +0200 Subject: Ignore password hashes in consistent manner This changes the getent and getent.ldap tests to ignore password hashes that may be present in shadow lookups in a consistent manner. This also adds minor compatibility improvements. --- tests/test_ldapcmds.sh | 11 +++++++---- tests/test_nsscmds.sh | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/test_ldapcmds.sh b/tests/test_ldapcmds.sh index 8485d2b..a9c2efb 100755 --- a/tests/test_ldapcmds.sh +++ b/tests/test_ldapcmds.sh @@ -37,7 +37,7 @@ export PYTHONPATH "$srcdir/testenv.sh" check_nslcd || exit 77 # if Python is missing, ignore -if ! ${python} --version > /dev/null 2> /dev/null +if [ -z "${python}" ] || ! ${python} --version > /dev/null 2> /dev/null then echo "Python (${python}) not found" exit 77 @@ -472,13 +472,16 @@ EOM echo "test_ldapcmds.sh: testing shadow..." -# NOTE: the output of this should depend on whether we are root or not +# function to remove the password field from output +rmpasswd() { + sed 's/^\([^:]*\):[^:]*:/\1:*:/' +} -check "getent.ldap shadow ecordas | sed 's/^\([^:]*\):[^:]*:/\1:*:/'" << EOM +check "getent.ldap shadow ecordas | rmpasswd" << EOM ecordas:*::::7:2::0 EOM -check "getent.ldap shadow adishaw | sed 's/^\([^:]*\):[^:]*:/\1:*:/'" << EOM +check "getent.ldap shadow adishaw | rmpasswd" << EOM adishaw:*:12302:::7:2::0 EOM diff --git a/tests/test_nsscmds.sh b/tests/test_nsscmds.sh index 846ad43..ef489e2 100755 --- a/tests/test_nsscmds.sh +++ b/tests/test_nsscmds.sh @@ -490,13 +490,16 @@ if grep '^shadow.*ldap' /etc/nsswitch.conf > /dev/null 2>&1 then echo "test_nsscmds.sh: testing shadow..." -# NOTE: the output of this should depend on whether we are root or not +# function to remove the password field from output +rmpasswd() { + sed 's/^\([^:]*\):[^:]*:/\1:*:/' +} -check "getent shadow ecordas" << EOM +check "getent shadow ecordas | rmpasswd" << EOM ecordas:*::::7:2::0 EOM -check "getent shadow adishaw" << EOM +check "getent shadow adishaw | rmpasswd" << EOM adishaw:*:12302:::7:2::0 EOM -- cgit v1.2.3