Add more tests for pw(8) useradd.

PR:		195832
Submitted by:	Robert O'Neil <oneil.rs@gmail.com>
Approved by:	will
This commit is contained in:
Brad Davis 2014-12-09 20:36:07 +00:00
parent 2ee6121f79
commit 2ffc3ce50a
2 changed files with 42 additions and 1 deletions

View File

@ -5,8 +5,9 @@ TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/useradd
TESTSDIR= ${TESTSBASE}/usr.sbin/pw
ATF_TESTS_SH= pw_delete pw_lock pw_modify pw_etcdir
ATF_TESTS_SH= pw_add pw_delete pw_etcdir pw_lock pw_modify
TEST_METADATA.pw_add+= required_user="root"
TEST_METADATA.pw_delete+= required_user="root"
TEST_METADATA.pw_modify+= required_user="root"

40
usr.sbin/pw/tests/pw_add.sh Executable file
View File

@ -0,0 +1,40 @@
# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
# Test add user
atf_test_case user_add
user_add_body() {
populate_etc_skel
atf_check -s exit:0 ${PW} useradd test
atf_check -s exit:0 -o match:"^test:.*" \
grep "^test:.*" $HOME/master.passwd
}
atf_test_case user_add_comments
user_add_comments_body() {
populate_etc_skel
atf_check -s exit:0 ${PW} useradd test -c "Test User,work,123,456"
atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
}
atf_test_case user_add_comments_invalid
user_add_comments_invalid_body() {
populate_etc_skel
atf_check -s exit:65 -e match:"invalid character" \
${PW} useradd test -c "Test User,work,123:456,456"
atf_check -s exit:1 -o empty \
grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
}
atf_init_test_cases() {
atf_add_test_case user_add
atf_add_test_case user_add_comments
atf_add_test_case user_add_comments_invalid
}