1 2# Import helper functions 3. $(atf_get_srcdir)/helper_functions.shin 4 5# Test locking and unlocking a user account 6atf_test_case user_locking cleanup 7user_locking_body() { 8 populate_etc_skel 9 ${PW} useradd test || atf_fail "Creating test user" 10 ${PW} lock test || atf_fail "Locking the user" 11 atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \ 12 grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd 13 ${PW} unlock test || atf_fail "Locking the user" 14 atf_check -s exit:0 -o match:"^test:\*:1001:" \ 15 grep "^test:\*:1001:" $HOME/master.passwd 16} 17 18atf_test_case numeric_locking cleanup 19numeric_locking_body() { 20 populate_etc_skel 21 ${PW} useradd test || atf_fail "Creating test user" 22 ${PW} lock 1001 || atf_fail "Locking the user" 23 atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \ 24 grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd 25 ${PW} unlock 1001 || atf_fail "Unlocking the user" 26 atf_check -s exit:0 -o match:"^test:\*:1001:" \ 27 grep "^test:\*:1001:" $HOME/master.passwd 28 # Now numeric names 29 ${PW} useradd -n 1001 || atf_fail "Creating test user" 30 ${PW} lock 1001 || atf_fail "Locking the user" 31 atf_check -s exit:0 -o match:"^1001:\*LOCKED\*\*:1002:" \ 32 grep "^1001:\*LOCKED\*\*:1002:" $HOME/master.passwd 33 ${PW} unlock 1001 || atf_fail "Unlocking the user" 34 atf_check -s exit:0 -o match:"^1001:\*:1002:" \ 35 grep "^1001:\*:1002:" $HOME/master.passwd 36} 37 38atf_init_test_cases() { 39 atf_add_test_case user_locking 40 atf_add_test_case numeric_locking 41} 42