Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2017-06-25 16:25:27 +0200
committerArthur de Jong <arthur@arthurdejong.org>2017-06-25 16:48:53 +0200
commit7920d85ef806cda6a37db16aff75f895cc67a3e1 (patch)
treec7d339908c9242c31aed89ec86af9a0562a574e0
parent65695aa1d0fbc0a4aa5e7b1bb28c66fbb4879e01 (diff)
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.
-rwxr-xr-xtests/test_ldapcmds.sh11
-rwxr-xr-xtests/test_nsscmds.sh9
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