diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2014-12-10 06:43:16 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2014-12-10 06:43:16 +0000 |
commit | e55e3502008b47514b4e52bfe0416ac4625a128e (patch) | |
tree | 1ab069d8f9454b1d813752344a49e4f339875234 /pw/tests/pw_usermod.sh | |
parent | 164700bfc553029e369b0aeca106acffc404bece (diff) | |
parent | b4ea158866fbdc9a9c5b75c0f10ca72ccb0733f4 (diff) | |
download | pw-darwin-e55e3502008b47514b4e52bfe0416ac4625a128e.tar.gz pw-darwin-e55e3502008b47514b4e52bfe0416ac4625a128e.tar.zst pw-darwin-e55e3502008b47514b4e52bfe0416ac4625a128e.zip |
MFhead @ r275663
Diffstat (limited to 'pw/tests/pw_usermod.sh')
-rwxr-xr-x | pw/tests/pw_usermod.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/pw/tests/pw_usermod.sh b/pw/tests/pw_usermod.sh new file mode 100755 index 0000000..f5bac78 --- /dev/null +++ b/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 +} |