summaryrefslogtreecommitdiffstats
path: root/pw/tests
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-06-07 19:33:25 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-06-07 19:33:25 +0000
commitfd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792 (patch)
tree021a93deb9a9c3dc06d5d56be3addb65fa7c988c /pw/tests
parentecddcdd12d894cb5522d8c22536d53f1c8cce857 (diff)
downloadpw-darwin-fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792.tar.gz
pw-darwin-fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792.tar.zst
pw-darwin-fd1b4fc5f4c3f3eb1ee87ab1f07b7640efd15792.zip
In case of rename validate the length of the new name
Check early that the new name fits MAXLOGNAME and store it in pwconf
Diffstat (limited to 'pw/tests')
-rwxr-xr-xpw/tests/pw_groupmod.sh11
-rwxr-xr-xpw/tests/pw_usermod.sh27
2 files changed, 35 insertions, 3 deletions
diff --git a/pw/tests/pw_groupmod.sh b/pw/tests/pw_groupmod.sh
index ad7ad0a..9ea8a6d 100755
--- a/pw/tests/pw_groupmod.sh
+++ b/pw/tests/pw_groupmod.sh
@@ -71,10 +71,21 @@ do_not_duplicate_group_on_gid_change_body() {
atf_check -o inline:"testgroup:*:12345:\n" -s exit:0 -x grep "^testgroup" ${HOME}/group
}
+atf_test_case groupmod_rename
+groupmod_rename_body() {
+ populate_etc_skel
+
+ atf_check -s exit:0 ${PW} groupadd foo
+ atf_check -s exit:0 ${PW} groupmod foo -l bar
+ atf_check -s exit:0 -o match:"^bar:.*" \
+ grep "^bar:.*" ${HOME}/group
+}
+
atf_init_test_cases() {
atf_add_test_case groupmod_user
atf_add_test_case groupmod_invalid_user
atf_add_test_case groupmod_bug_193704
atf_add_test_case usermod_bug_185666
atf_add_test_case do_not_duplicate_group_on_gid_change
+ atf_add_test_case groupmod_rename
}
diff --git a/pw/tests/pw_usermod.sh b/pw/tests/pw_usermod.sh
index 88bd316..dbc6481 100755
--- a/pw/tests/pw_usermod.sh
+++ b/pw/tests/pw_usermod.sh
@@ -100,13 +100,34 @@ user_mod_name_noupdate_body() {
grep "^foo:.*" $HOME/master.passwd
}
+atf_test_case user_mod_rename
+user_mod_rename_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_test_case user_mod_rename_too_long
+user_mod_rename_too_long_body() {
+ populate_etc_skel
+
+ atf_check -s exit:0 ${PW} useradd foo
+ atf_check -s exit:64 -e match:"too long" ${PW} usermod foo \
+ -l name_very_very_very_very_very_long
+}
+
atf_init_test_cases() {
atf_add_test_case user_mod
atf_add_test_case user_mod_noupdate
atf_add_test_case user_mod_comments
atf_add_test_case user_mod_comments_noupdate
- atf_add_test_case user_mod_comments_invalid
- atf_add_test_case user_mod_comments_invalid_noupdate
- atf_add_test_case user_mod_name
+ atf_add_test_case user_mod_comments_invalid
+ atf_add_test_case user_mod_comments_invalid_noupdate
+ atf_add_test_case user_mod_rename
atf_add_test_case user_mod_name_noupdate
+ atf_add_test_case user_mod_rename
+ atf_add_test_case user_mod_rename_too_long
}