diff options
author | brd <brd@FreeBSD.org> | 2014-12-09 20:36:07 +0000 |
---|---|---|
committer | brd <brd@FreeBSD.org> | 2014-12-09 20:36:07 +0000 |
commit | eced0880b980b894032bcf0547bb97c7ea50f3fa (patch) | |
tree | 4ff0597bfbcfc3fb0cee06109fee313056e5ee9b /usr.sbin | |
parent | c186a7a46b98f8fac1f7664b19f8dbc6c2fd9ab3 (diff) | |
download | FreeBSD-src-eced0880b980b894032bcf0547bb97c7ea50f3fa.zip FreeBSD-src-eced0880b980b894032bcf0547bb97c7ea50f3fa.tar.gz |
Add more tests for pw(8) useradd.
PR: 195832
Submitted by: Robert O'Neil <oneil.rs@gmail.com>
Approved by: will
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pw/tests/Makefile | 3 | ||||
-rwxr-xr-x | usr.sbin/pw/tests/pw_add.sh | 40 |
2 files changed, 42 insertions, 1 deletions
diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile index 6bc9433..aa774ef 100644 --- a/usr.sbin/pw/tests/Makefile +++ b/usr.sbin/pw/tests/Makefile @@ -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" diff --git a/usr.sbin/pw/tests/pw_add.sh b/usr.sbin/pw/tests/pw_add.sh new file mode 100755 index 0000000..fb2e33f --- /dev/null +++ b/usr.sbin/pw/tests/pw_add.sh @@ -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 +} |