From d9e43f4c15482b1b306ec63e7ac4d1c78da152ea Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 16 Dec 2014 14:50:33 +0000 Subject: Add tests for pw -N PR: 150449 Submitted by: Robert O'Neil Approved by: will --- pw/tests/pw_useradd.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'pw/tests/pw_useradd.sh') diff --git a/pw/tests/pw_useradd.sh b/pw/tests/pw_useradd.sh index fb2e33f..2930c41 100755 --- a/pw/tests/pw_useradd.sh +++ b/pw/tests/pw_useradd.sh @@ -13,7 +13,16 @@ user_add_body() { grep "^test:.*" $HOME/master.passwd } +# Test add user with option -N +atf_test_case user_add_noupdate +user_add_noupdate_body() { + populate_etc_skel + + atf_check -s exit:0 -o match:"^test:.*" ${PW} useradd test -N + atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd +} +# Test add user with comments atf_test_case user_add_comments user_add_comments_body() { populate_etc_skel @@ -23,6 +32,17 @@ user_add_comments_body() { grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd } +# Test add user with comments and option -N +atf_test_case user_add_comments_noupdate +user_add_comments_noupdate_body() { + populate_etc_skel + + atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \ + ${PW} useradd test -c "Test User,work,123,456" -N + atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd +} + +# Test add user with invalid comments atf_test_case user_add_comments_invalid user_add_comments_invalid_body() { populate_etc_skel @@ -33,8 +53,21 @@ user_add_comments_invalid_body() { grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd } +# Test add user with invalid comments and option -N +atf_test_case user_add_comments_invalid_noupdate +user_add_comments_invalid_noupdate_body() { + populate_etc_skel + + atf_check -s exit:65 -e match:"invalid character" \ + ${PW} useradd test -c "Test User,work,123:456,456" -N + atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd +} + atf_init_test_cases() { atf_add_test_case user_add + atf_add_test_case user_add_noupdate atf_add_test_case user_add_comments + atf_add_test_case user_add_comments_noupdate atf_add_test_case user_add_comments_invalid + atf_add_test_case user_add_comments_invalid_noupdate } -- cgit v1.2.3-56-ge451