summaryrefslogtreecommitdiffstats
path: root/pw/tests/pw_usermod.sh
diff options
context:
space:
mode:
authorBrad Davis <brd@FreeBSD.org>2014-12-09 22:11:56 +0000
committerBrad Davis <brd@FreeBSD.org>2014-12-09 22:11:56 +0000
commita1f436b85865da2f74303520014092c96f2dcde5 (patch)
treeb85591e53c9498202b755d39f09634160339d9af /pw/tests/pw_usermod.sh
parent0a90b89c483dd20bd105cbbd9effc194c132d940 (diff)
downloadpw-darwin-a1f436b85865da2f74303520014092c96f2dcde5.tar.gz
pw-darwin-a1f436b85865da2f74303520014092c96f2dcde5.tar.zst
pw-darwin-a1f436b85865da2f74303520014092c96f2dcde5.zip
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 'pw/tests/pw_usermod.sh')
-rwxr-xr-xpw/tests/pw_usermod.sh56
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
+}