diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-07-04 15:27:04 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-07-04 15:27:04 +0000 |
commit | a723ebdc0a4d074c12bedca8c7d483a13105c295 (patch) | |
tree | c041c77aaa80a7890f98192b8b6c245c94f7166c /pw/tests | |
parent | cc666f9d1a91a808b95a347674765342e3a354ef (diff) | |
download | pw-darwin-a723ebdc0a4d074c12bedca8c7d483a13105c295.tar.gz pw-darwin-a723ebdc0a4d074c12bedca8c7d483a13105c295.tar.zst pw-darwin-a723ebdc0a4d074c12bedca8c7d483a13105c295.zip |
Validate input of pw usermod -h and pwusermod -H
Push the code that set the password into a separate function to improve
readability
Add regression tests about pw usermod -h and pw usermod -H
Diffstat (limited to 'pw/tests')
-rwxr-xr-x | pw/tests/pw_usermod.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pw/tests/pw_usermod.sh b/pw/tests/pw_usermod.sh index dbc6481..006bb2c 100755 --- a/pw/tests/pw_usermod.sh +++ b/pw/tests/pw_usermod.sh @@ -119,6 +119,41 @@ user_mod_rename_too_long_body() { -l name_very_very_very_very_very_long } +atf_test_case user_mod_h +user_mod_h_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd foo + atf_check -s exit:0 ${PW} usermod foo -h 0 <<- EOF + $(echo a) + EOF + atf_check -s exit:0 -o not-match:"^foo:\*:.*" \ + grep "^foo" ${HOME}/master.passwd + atf_check -s exit:0 ${PW} usermod foo -h - <<- EOF + $(echo b) + EOF + atf_check -s exit:0 -o match:"^foo:\*:.*" \ + grep "^foo" ${HOME}/master.passwd + atf_check -e inline:"pw: '-h' expects a file descriptor or '-'\n" \ + -s exit:64 ${PW} usermod foo -h a <<- EOF + $(echo a) + EOF +} + +atf_test_case user_mod_H +user_mod_H_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} useradd foo + atf_check -s exit:0 ${PW} usermod foo -H 0 <<- EOF + $(echo a) + EOF + atf_check -s exit:0 -o match:"^foo:a:.*" \ + grep "^foo" ${HOME}/master.passwd + atf_check -s exit:64 -e inline:"pw: '-H' expects a file descriptor\n" \ + ${PW} usermod foo -H - +} + atf_init_test_cases() { atf_add_test_case user_mod atf_add_test_case user_mod_noupdate @@ -130,4 +165,6 @@ atf_init_test_cases() { atf_add_test_case user_mod_name_noupdate atf_add_test_case user_mod_rename atf_add_test_case user_mod_rename_too_long + atf_add_test_case user_mod_h + atf_add_test_case user_mod_H } |