freebsd-skq/usr.sbin/pw/tests/pw_lock_test.sh
ngie 5ad4f59bfb Rename tests from <foo> to <foo>_test to match the FreeBSD test suite
naming scheme

usr.bin/diff/diff_test was renamed to usr.bin/diff/netbsd_diff_test
to avoid collisions with the renamed FreeBSD test.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-23 03:28:24 +00:00

43 lines
1.4 KiB
Bash
Executable File

# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
# Test locking and unlocking a user account
atf_test_case user_locking cleanup
user_locking_body() {
populate_etc_skel
${PW} useradd test || atf_fail "Creating test user"
${PW} lock test || atf_fail "Locking the user"
atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \
grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd
${PW} unlock test || atf_fail "Locking the user"
atf_check -s exit:0 -o match:"^test:\*:1001:" \
grep "^test:\*:1001:" $HOME/master.passwd
}
atf_test_case numeric_locking cleanup
numeric_locking_body() {
populate_etc_skel
${PW} useradd test || atf_fail "Creating test user"
${PW} lock 1001 || atf_fail "Locking the user"
atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \
grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd
${PW} unlock 1001 || atf_fail "Unlocking the user"
atf_check -s exit:0 -o match:"^test:\*:1001:" \
grep "^test:\*:1001:" $HOME/master.passwd
# Now numeric names
${PW} useradd -n 1001 || atf_fail "Creating test user"
${PW} lock 1001 || atf_fail "Locking the user"
atf_check -s exit:0 -o match:"^1001:\*LOCKED\*\*:1002:" \
grep "^1001:\*LOCKED\*\*:1002:" $HOME/master.passwd
${PW} unlock 1001 || atf_fail "Unlocking the user"
atf_check -s exit:0 -o match:"^1001:\*:1002:" \
grep "^1001:\*:1002:" $HOME/master.passwd
}
atf_init_test_cases() {
atf_add_test_case user_locking
atf_add_test_case numeric_locking
}