diff options
author | brd <brd@FreeBSD.org> | 2014-12-09 22:11:56 +0000 |
---|---|---|
committer | brd <brd@FreeBSD.org> | 2014-12-09 22:11:56 +0000 |
commit | 0534d4b8fceeb357f8ebee3e08b8a3cf1de0913e (patch) | |
tree | 0f9b23e18a52bd5fcfe22e5948cec6ffbe753bdd /usr.sbin | |
parent | 37438c711e987be47bbbbc259c9c3c56f8e9dcd3 (diff) | |
download | FreeBSD-src-0534d4b8fceeb357f8ebee3e08b8a3cf1de0913e.zip FreeBSD-src-0534d4b8fceeb357f8ebee3e08b8a3cf1de0913e.tar.gz |
Add some tests for user modification. [1]
Fix a missing test in the Makefile from my previous commit.
PR: 195834 [1]
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 | 4 | ||||
-rwxr-xr-x | usr.sbin/pw/tests/pw_usermod.sh | 56 |
2 files changed, 59 insertions, 1 deletions
diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile index c490059..543b6dc 100644 --- a/usr.sbin/pw/tests/Makefile +++ b/usr.sbin/pw/tests/Makefile @@ -5,11 +5,13 @@ TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/useradd TESTSDIR= ${TESTSBASE}/usr.sbin/pw -ATF_TESTS_SH= pw_etcdir pw_lock pw_groupmod pw_useradd pw_userdel +ATF_TESTS_SH= pw_etcdir pw_lock pw_groupdel pw_groupmod pw_useradd pw_userdel pw_usermod +TEST_METADATA.pw_groupdel+= required_user="root" TEST_METADATA.pw_groupmod+= required_user="root" TEST_METADATA.pw_useradd+= required_user="root" TEST_METADATA.pw_userdel+= required_user="root" +TEST_METADATA.pw_usermod+= required_user="root" FILES= group helper_functions.shin master.passwd FILESDIR= ${TESTSDIR} diff --git a/usr.sbin/pw/tests/pw_usermod.sh b/usr.sbin/pw/tests/pw_usermod.sh new file mode 100755 index 0000000..f5bac78 --- /dev/null +++ b/usr.sbin/pw/tests/pw_usermod.sh @@ -0,0 +1,56 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + +# Test modifying a user +atf_test_case user_mod +user_mod_body() { + populate_etc_skel + + atf_check -s exit:67 -e match:"no such user" ${PW} usermod test + atf_check -s exit:0 ${PW} useradd test + atf_check -s exit:0 ${PW} usermod test + atf_check -s exit:0 -o match:"^test:.*" \ + grep "^test:.*" $HOME/master.passwd +} + +# Test modifying a user with comments +atf_test_case user_mod_comments +user_mod_comments_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd test -c "Test User,home,123,456" + atf_check -s exit:0 ${PW} usermod 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 +} + +# Test modifying a user with invalid comments +atf_test_case user_mod_comments_invalid +user_mod_comments_invalid_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd test + atf_check -s exit:65 -e match:"invalid character" \ + ${PW} usermod 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 +} + +# Test modifying a user name with -l +atf_test_case user_mod_name +user_mod_name_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd foo + atf_check -s exit:0 ${PW} usermod foo -l "bar" + atf_check -s exit:0 -o match:"^bar:.*" \ + grep "^bar:.*" $HOME/master.passwd +} +atf_init_test_cases() { + atf_add_test_case user_mod + atf_add_test_case user_mod_comments + atf_add_test_case user_mod_comments_invalid + atf_add_test_case user_mod_name +} |