summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2013-10-29 23:26:58 +0100
committerArthur de Jong <arthur@arthurdejong.org>2013-10-29 23:26:58 +0100
commitef0eddaad62f3b94689b7339ffc18d7873adbe6a (patch)
tree83a13e9abeaab9cc685e891e4fb82959fcff9d22 /tests
parentf8af48faa18b6d9017ea64f4df2d6ee2b1743df3 (diff)
Portability fixes to environment tests
This mostly tries to reduce the influences of the test environment (local users and groups) on the tests. This uses another username (vsefcovic) in the PAM tests instead of the user arthur to avoid clashes with existing users. The PAM tests are skipped if passwd claims that it cannot modify LDAP passwords (for FreeBSD).
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_myldap.sh5
-rwxr-xr-xtests/test_nsscmds.sh9
-rw-r--r--tests/test_pamcmds.expect16
3 files changed, 18 insertions, 12 deletions
diff --git a/tests/test_myldap.sh b/tests/test_myldap.sh
index c5b71d0..4f48d19 100755
--- a/tests/test_myldap.sh
+++ b/tests/test_myldap.sh
@@ -26,7 +26,7 @@
set -e
# get LDAP config
-srcdir="${srcdir-"."}"
+srcdir="${srcdir-`dirname "$0"`}"
cfgfile="$srcdir/nslcd-test.conf"
uri=`sed -n 's/^uri *//p' "$cfgfile" | head -n 1`
base="dc=test,dc=tld"
@@ -35,4 +35,5 @@ base="dc=test,dc=tld"
"$srcdir/testenv.sh" check_ldap "$uri" "$base" || exit 77
# just execute test_myldap
-exec ./test_myldap
+export srcdir
+exec "$srcdir/test_myldap"
diff --git a/tests/test_nsscmds.sh b/tests/test_nsscmds.sh
index cf997fc..2c5ffc6 100755
--- a/tests/test_nsscmds.sh
+++ b/tests/test_nsscmds.sh
@@ -139,8 +139,9 @@ echo "test_nsscmds.sh: testing group..."
sortgroup() {
while read line
do
- group="$(echo "$line" | sed 's/^\([^:]*:[^:]*:[^:]*\)\(:\(.*\)\)*$/\1:/')"
- members="$(echo "$line" | sed -n 's/^\([^:]*:[^:]*:[^:]*\)\(:\(.*\)\)*$/\3/p' | tr ',' '\n' | sort | tr '\n' ',' | sed 's/,$//')"
+ group="`echo "$line" | sed 's/^\([^:]*:[^:]*:[^:]*\).*$/\1:/'`"
+ members="`echo "$line" | sed -n 's/^[^:]*:[^:]*:[^:]*:\(.*\)$/\1/p' | tr ',' '\n' | sort | tr '\n' ','`"
+ members="`echo "$members" | sed 's/,$//'`"
echo "${group}${members}"
done
}
@@ -171,8 +172,8 @@ check "groups testuser4 | sed 's/^.* *: *//'" << EOM
users testgroup testgroup2
EOM
-check "getent group | egrep '^(testgroup|users):' | sortgroup" << EOM
-users:x:100:
+check "getent group | egrep '^(testgroup|users|root):' | sortgroup" << EOM
+$(egrep '^(testgroup|users|root):' /etc/group)
testgroup:*:6100:arthur,test,testuser4
users:*:100:arthur,test
EOM
diff --git a/tests/test_pamcmds.expect b/tests/test_pamcmds.expect
index 7d5e3be..2379090 100644
--- a/tests/test_pamcmds.expect
+++ b/tests/test_pamcmds.expect
@@ -36,7 +36,7 @@ proc abort {} {
proc reset_password {} {
global expect_out
send_user "test_pamcmds.expect: resetting passwd...\n"
- spawn passwd arthur
+ spawn passwd vsefcovic
expect {
"LDAP administrator password" { send "test\r"; exp_continue }
-regexp "(New|Retype new)( UNIX)? password:" { send "test\r"; exp_continue }
@@ -44,6 +44,10 @@ proc reset_password {} {
"passwd: all authentication tokens updated successfully." {}
"Invalid credentials" abort
"Authentication token manipulation error" abort
+ "passwd: Sorry, `passwd' can only change passwords for local or NIS users." {
+ send_user "test_pamcmds.expect: passwd not using PAM\n"
+ exit 77
+ }
default abort
}
#close
@@ -126,11 +130,11 @@ proc test_login_unknown {uid passwd} {
# test incorrect password
send_user "test_pamcmds.expect: testing incorrect password...\n"
-test_login_authfail arthur wrongpassword
+test_login_authfail vsefcovic wrongpassword
# test correct password
send_user "test_pamcmds.expect: testing correct password...\n"
-test_login_ok arthur test
+test_login_ok vsefcovic test
# change password using incorrect old password
send_user "test_pamcmds.expect: testing password change with incorrect password...\n"
@@ -174,11 +178,11 @@ expect "\$ "
# logging in with the old password should fail now
send_user "test_pamcmds.expect: testing old password...\n"
-test_login_authfail arthur test
+test_login_authfail vsefcovic test
# test correct password
send_user "test_pamcmds.expect: testing new password...\n"
-test_login_ok arthur DuhevOlNoz5
+test_login_ok vsefcovic DuhevOlNoz5
# test invalid username
send_user "test_pamcmds.expect: testing with unknown username...\n"
@@ -192,7 +196,7 @@ test_login_authfail root anypassword
send_user "test_pamcmds.expect: testing with nobody...\n"
test_login_authfail nobody anypassword
-# close the shell (first log of arthur)
+# close the shell (first log off vsefcovic)
send "exit\r"
expect "\$ "
send "exit\r"