Break out the tests into a file per command and clean up some long lines
Approved by: will
This commit is contained in:
parent
2ffc3ce50a
commit
bfce762f3f
@ -5,11 +5,11 @@ TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/useradd
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/usr.sbin/pw
|
||||
|
||||
ATF_TESTS_SH= pw_add pw_delete pw_etcdir pw_lock pw_modify
|
||||
ATF_TESTS_SH= pw_etcdir pw_lock pw_groupmod pw_useradd pw_userdel
|
||||
|
||||
TEST_METADATA.pw_add+= required_user="root"
|
||||
TEST_METADATA.pw_delete+= required_user="root"
|
||||
TEST_METADATA.pw_modify+= required_user="root"
|
||||
TEST_METADATA.pw_groupmod+= required_user="root"
|
||||
TEST_METADATA.pw_useradd+= required_user="root"
|
||||
TEST_METADATA.pw_userdel+= required_user="root"
|
||||
|
||||
FILES= group helper_functions.shin master.passwd
|
||||
FILESDIR= ${TESTSDIR}
|
||||
|
24
usr.sbin/pw/tests/pw_groupdel.sh
Executable file
24
usr.sbin/pw/tests/pw_groupdel.sh
Executable file
@ -0,0 +1,24 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# Import helper functions
|
||||
. $(atf_get_srcdir)/helper_functions.shin
|
||||
|
||||
|
||||
# Test to make sure we do not accidentially delete wheel when trying to delete
|
||||
# an unknown group
|
||||
atf_test_case group_do_not_delete_wheel_if_group_unknown
|
||||
group_do_not_delete_wheel_if_group_unknown_head() {
|
||||
atf_set "descr" "Make sure we do not consider gid 0 an unknown group"
|
||||
}
|
||||
group_do_not_delete_wheel_if_group_unknown_body() {
|
||||
populate_etc_skel
|
||||
atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
|
||||
atf_check -e inline:"pw: -g expects a number\n" -s exit:64 -x \
|
||||
${PW} groupdel -g I_do_not_exist
|
||||
atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
|
||||
}
|
||||
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case group_do_not_delete_wheel_if_group_unknown
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
# Import helper functions
|
||||
. $(atf_get_srcdir)/helper_functions.shin
|
||||
|
||||
|
||||
# Test that a user can be deleted when another user is part of this
|
||||
# user's default group and does not go into an infinate loop.
|
||||
# PR: 191427
|
||||
@ -18,30 +19,19 @@ rmuser_seperate_group_body() {
|
||||
${PW} userdel test || atf_fail "Delete the test user"
|
||||
}
|
||||
|
||||
atf_test_case group_do_not_delete_wheel_if_group_unknown
|
||||
group_do_not_delete_wheel_if_group_unknown_head() {
|
||||
atf_set "descr" "Make sure we do not consider gid 0 an unknown group"
|
||||
}
|
||||
|
||||
group_do_not_delete_wheel_if_group_unknown_body() {
|
||||
populate_etc_skel
|
||||
atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
|
||||
atf_check -e inline:"pw: -g expects a number\n" -s exit:64 -x ${PW} groupdel -g I_do_not_exist
|
||||
atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
|
||||
}
|
||||
|
||||
atf_test_case user_do_not_try_to_delete_root_if_user_unknown
|
||||
user_do_not_try_to_delete_root_if_user_unknown_head() {
|
||||
atf_set "descr" "Make sure not to try to remove root if deleting an unknown user"
|
||||
atf_set "descr" \
|
||||
"Make sure not to try to remove root if deleting an unknown user"
|
||||
}
|
||||
|
||||
user_do_not_try_to_delete_root_if_user_unknown_body() {
|
||||
populate_etc_skel
|
||||
atf_check -e inline:"pw: -u expects a number\n" -s exit:64 -x ${PW} userdel -u plop
|
||||
atf_check -e inline:"pw: -u expects a number\n" -s exit:64 -x \
|
||||
${PW} userdel -u plop
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case rmuser_seperate_group
|
||||
atf_add_test_case group_do_not_delete_wheel_if_group_unknown
|
||||
atf_add_test_case user_do_not_try_to_delete_root_if_user_unknown
|
||||
}
|
Loading…
Reference in New Issue
Block a user