2 # $Id: ckpasswd.t 5572 2002-08-12 06:01:09Z rra $
4 # Test suite for ckpasswd.
6 # The count starts at 1 and is updated each time ok is printed. printcount
7 # takes "ok" or "not ok".
11 count=`expr $count + 1`
14 # Run ckpasswd, expecting it to succeed. Takes a username, a password, any
15 # additional options, and the expected output string.
17 output=`$ckpasswd -u "$1" -p "$2" $3 2>&1`
19 if test $status = 0 && test x"$output" = x"$4" ; then
28 # Run ckpasswd, feeding it the username and password on stdin in the same way
29 # that nnrpd would. Takes a username, a password, any additional options, and
30 # the expected output string.
32 output=`( echo ClientAuthname: $1 ; echo ClientPassword: $2 ) \
35 if test $status = 0 && test x"$output" = x"$4" ; then
44 # Run ckpasswd, expecting it to fail, and make sure it fails with status 1 and
45 # prints out the right error message. Takes a username, a password, any
46 # additional options, and the expected output string.
48 output=`$ckpasswd -u "$1" -p "$2" $3 2>&1`
50 if test $status = 1 && test x"$output" = x"$4" ; then
59 # Make sure we're in the right directory.
60 for dir in . authprogs tests/authprogs ; do
61 test -f "$dir/passwd" && cd $dir
63 ckpasswd=../../authprogs/ckpasswd
65 # Print the test count.
68 # First, run the tests that we expect to succeed.
69 runsuccess "foo" "foopass" "-f passwd" "User:foo"
70 runsuccess "bar" "barpass" "-f passwd" "User:bar"
71 runsuccess "baz" "" "-f passwd" "User:baz"
72 runpipe "foo" "foopass" "-f passwd" "User:foo"
74 # Now, run the tests that we expect to fail.
75 runfailure "foo" "barpass" "-f passwd" \
76 "ckpasswd: invalid password for user foo"
77 runfailure "who" "foopass" "-f passwd" \
78 "ckpasswd: user who unknown"
79 runfailure "" "foopass" "-f passwd" \
80 "ckpasswd: null username"