3 # Import helper functions
4 . $(atf_get_srcdir)/helper_functions.shin
11 atf_check -s exit:0 ${PW} useradd test
12 atf_check -s exit:0 -o match:"^test:.*" \
13 grep "^test:.*" $HOME/master.passwd
16 # Test add user with option -N
17 atf_test_case user_add_noupdate
18 user_add_noupdate_body() {
21 atf_check -s exit:0 -o match:"^test:.*" ${PW} useradd test -N
22 atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
25 # Test add user with comments
26 atf_test_case user_add_comments
27 user_add_comments_body() {
30 atf_check -s exit:0 ${PW} useradd test -c "Test User,work,123,456"
31 atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
32 grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
35 # Test add user with comments and option -N
36 atf_test_case user_add_comments_noupdate
37 user_add_comments_noupdate_body() {
40 atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
41 ${PW} useradd test -c "Test User,work,123,456" -N
42 atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
45 # Test add user with invalid comments
46 atf_test_case user_add_comments_invalid
47 user_add_comments_invalid_body() {
50 atf_check -s exit:65 -e match:"invalid character" \
51 ${PW} useradd test -c "Test User,work,123:456,456"
52 atf_check -s exit:1 -o empty \
53 grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
56 # Test add user with invalid comments and option -N
57 atf_test_case user_add_comments_invalid_noupdate
58 user_add_comments_invalid_noupdate_body() {
61 atf_check -s exit:65 -e match:"invalid character" \
62 ${PW} useradd test -c "Test User,work,123:456,456" -N
63 atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
66 atf_init_test_cases() {
67 atf_add_test_case user_add
68 atf_add_test_case user_add_noupdate
69 atf_add_test_case user_add_comments
70 atf_add_test_case user_add_comments_noupdate
71 atf_add_test_case user_add_comments_invalid
72 atf_add_test_case user_add_comments_invalid_noupdate