Add minimum regression tests for pw -R
This commit is contained in:
parent
3a6dcb1fad
commit
67eea76de0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285418
@ -2,11 +2,12 @@
|
||||
|
||||
# The pw command
|
||||
PW="pw -V ${HOME}"
|
||||
RPW="pw -R ${HOME}"
|
||||
|
||||
# Workdir to run tests in
|
||||
TESTDIR=$(atf_get_srcdir)
|
||||
|
||||
# Populate the files pw needs to use into $HOME/etc
|
||||
# Populate the files pw needs to use into $HOME
|
||||
populate_etc_skel() {
|
||||
cp ${TESTDIR}/master.passwd ${HOME} || \
|
||||
atf_fail "Populating master.passwd in ${HOME}"
|
||||
@ -16,3 +17,16 @@ populate_etc_skel() {
|
||||
pwd_mkdb -p -d ${HOME} ${HOME}/master.passwd || \
|
||||
atf_fail "generate passwd from master.passwd"
|
||||
}
|
||||
|
||||
# Populate the files pw needs to use into $HOME/etc
|
||||
populate_root_etc_skel() {
|
||||
mkdir ${HOME}/etc
|
||||
cp ${TESTDIR}/master.passwd ${HOME}/etc || \
|
||||
atf_fail "Populating master.passwd in ${HOME}/etc"
|
||||
cp ${TESTDIR}/group ${HOME}/etc || \
|
||||
atf_fail "Populating group in ${HOME}/etc"
|
||||
|
||||
# Generate the passwd file
|
||||
pwd_mkdb -p -d ${HOME}/etc ${HOME}//etc/master.passwd || \
|
||||
atf_fail "generate passwd from master.passwd"
|
||||
}
|
||||
|
@ -240,6 +240,21 @@ user_add_password_from_h_body() {
|
||||
EOF
|
||||
}
|
||||
|
||||
atf_test_case user_add_R
|
||||
user_add_R_body() {
|
||||
populate_root_etc_skel
|
||||
|
||||
atf_check -s exit:0 ${RPW} useradd foo
|
||||
mkdir -p ${HOME}/home
|
||||
atf_check -s exit:0 ${RPW} useradd bar -m
|
||||
test -d ${HOME}/home/bar || atf_fail "Directory not created"
|
||||
atf_check -s exit:0 ${RPW} userdel bar
|
||||
test -d ${HOME}/home/bar || atf_fail "Directory removed"
|
||||
# atf_check -s exit:0 ${RPW} useradd bar
|
||||
# atf_check -s exit:0 ${RPW} userdel bar -r
|
||||
# test -d ${HOME}/home/bar && atf_fail "Directory not removed"
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case user_add
|
||||
atf_add_test_case user_add_noupdate
|
||||
@ -261,4 +276,5 @@ atf_init_test_cases() {
|
||||
atf_add_test_case user_add_invalid_user_entry
|
||||
atf_add_test_case user_add_invalid_group_entry
|
||||
atf_add_test_case user_add_password_from_h
|
||||
atf_add_test_case user_add_R
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user