shadow/tests/chage/02/run.exp
Serge Hallyn b999d48941 Add tests from the old svn tree
We're losing the svn history (which we could probably keep if we tried
hard enough) but don't consider that worthwhile.

Note these tests are destructive, so run them only in a throwaway
environment like a chroot, container, or vm.

The tests/run.all script should be the one which launches all the tests.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-09-17 14:42:55 -05:00

84 lines
1.6 KiB
Plaintext
Executable File

#!/usr/bin/expect
set timeout 5
proc expect_error {} {
expect {
"chage: error changing fields" {
expect {
eof {
} default {
puts "\nFAIL"
exit 1
}
}
} default {
puts "\nFAIL"
exit 1
}
}
}
# I've not been able to put the opening bracket in the regular expressions
# If anyone knows...
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send -- "-2\r"
expect_error
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send "foo\r"
expect_error
# chage accepts to be given only spaces
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send -- " \r"
#expect_error
#
#chage may not parse all the arguments.
#This may be a problem is a date is provided instead of just a number
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send -- "1 2\r"
#expect_error
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send "11\r"
expect -re "Maximum Password Age .99999\]: "
send -- "-2\r"
expect_error
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send "\r"
expect -re "Maximum Password Age .99999\]: "
send "foo\r"
expect_error
# chage should verify the range of the arguments
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send "\r"
#expect -re "Maximum Password Age .99999\]: "
#send "100000\r"
#expect_error
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send "\r"
#expect -re "Maximum Password Age .99999\]: "
#send "\r"
#expect -re "Last Password Change \[(]YYYY-MM-DD\[)] .2005-07-25]: "
#send "12\n"
#expect_error
puts "\nPASS"
exit 0