View | Details | Raw Unified | Return to bug 195865
Collapse All | Expand All

(-)pw_useradd.sh (+33 lines)
Lines 13-19 Link Here
13
		grep "^test:.*" $HOME/master.passwd
13
		grep "^test:.*" $HOME/master.passwd
14
}
14
}
15
15
16
# Test add user with option -N
17
atf_test_case user_add_noupdate
18
user_add_noupdate_body() {
19
	populate_etc_skel
16
20
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
23
}
24
25
# Test add user with comments
17
atf_test_case user_add_comments
26
atf_test_case user_add_comments
18
user_add_comments_body() {
27
user_add_comments_body() {
19
	populate_etc_skel
28
	populate_etc_skel
Lines 23-28 Link Here
23
		grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
32
		grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
24
}
33
}
25
34
35
# Test add user with comments and option -N
36
atf_test_case user_add_comments_noupdate
37
user_add_comments_noupdate_body() {
38
	populate_etc_skel
39
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
43
}
44
45
# Test add user with invalid comments
26
atf_test_case user_add_comments_invalid
46
atf_test_case user_add_comments_invalid
27
user_add_comments_invalid_body() {
47
user_add_comments_invalid_body() {
28
	populate_etc_skel
48
	populate_etc_skel
Lines 33-40 Link Here
33
		grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
53
		grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
34
}
54
}
35
55
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() {
59
	populate_etc_skel
60
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
64
}
65
36
atf_init_test_cases() {
66
atf_init_test_cases() {
37
	atf_add_test_case user_add
67
	atf_add_test_case user_add
68
	atf_add_test_case user_add_noupdate
38
	atf_add_test_case user_add_comments
69
	atf_add_test_case user_add_comments
70
	atf_add_test_case user_add_comments_noupdate
39
	atf_add_test_case user_add_comments_invalid 
71
	atf_add_test_case user_add_comments_invalid 
72
	atf_add_test_case user_add_comments_invalid_noupdate
40
}
73
}
(-)pw_usermod.sh (+56 lines)
Lines 15-20 Link Here
15
		grep "^test:.*" $HOME/master.passwd
15
		grep "^test:.*" $HOME/master.passwd
16
}
16
}
17
17
18
# Test modifying a user with option -N
19
atf_test_case user_mod_noupdate
20
user_mod_noupdate_body() {
21
	populate_etc_skel
22
23
	atf_check -s exit:67 -e match:"no such user" ${PW} usermod test -N
24
	atf_check -s exit:0 ${PW} useradd test
25
	atf_check -s exit:0 -o match:"^test:.*" ${PW} usermod test -N
26
	atf_check -s exit:0 -o match:"^test:.*" \
27
		grep "^test:.*" $HOME/master.passwd
28
}
29
18
# Test modifying a user with comments
30
# Test modifying a user with comments
19
atf_test_case user_mod_comments
31
atf_test_case user_mod_comments
20
user_mod_comments_body() {
32
user_mod_comments_body() {
Lines 26-31 Link Here
26
		grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
38
		grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
27
}
39
}
28
40
41
# Test modifying a user with comments with option -N
42
atf_test_case user_mod_comments_noupdate
43
user_mod_comments_noupdate_body() {
44
	populate_etc_skel
45
46
	atf_check -s exit:0 ${PW} useradd test -c "Test User,home,123,456"
47
	atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
48
		${PW} usermod test -c "Test User,work,123,456" -N
49
	atf_check -s exit:0 -o match:"^test:.*:Test User,home,123,456:" \
50
		grep "^test:.*:Test User,home,123,456:" $HOME/master.passwd
51
}
52
29
# Test modifying a user with invalid comments
53
# Test modifying a user with invalid comments
30
atf_test_case user_mod_comments_invalid
54
atf_test_case user_mod_comments_invalid
31
user_mod_comments_invalid_body() {
55
user_mod_comments_invalid_body() {
Lines 36-43 Link Here
36
		${PW} usermod test -c "Test User,work,123:456,456"
60
		${PW} usermod test -c "Test User,work,123:456,456"
37
	atf_check -s exit:1 -o empty \
61
	atf_check -s exit:1 -o empty \
38
		grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
62
		grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
63
	atf_check -s exit:0 -o match:"^test:\*" \
64
		grep "^test:\*" $HOME/master.passwd
39
}
65
}
40
66
67
# Test modifying a user with invalid comments with option -N
68
atf_test_case user_mod_comments_invalid_noupdate
69
user_mod_comments_invalid_noupdate_body() {
70
	populate_etc_skel
71
72
	atf_check -s exit:0 ${PW} useradd test
73
	atf_check -s exit:65 -e match:"invalid character" \
74
		${PW} usermod test -c "Test User,work,123:456,456" -N
75
	atf_check -s exit:1 -o empty \
76
		grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
77
	atf_check -s exit:0 -o match:"^test:\*" \
78
		grep "^test:\*" $HOME/master.passwd
79
}
80
41
# Test modifying a user name with -l
81
# Test modifying a user name with -l
42
atf_test_case user_mod_name
82
atf_test_case user_mod_name
43
user_mod_name_body() {
83
user_mod_name_body() {
Lines 48-56 Link Here
48
	atf_check -s exit:0 -o match:"^bar:.*" \
88
	atf_check -s exit:0 -o match:"^bar:.*" \
49
		grep "^bar:.*" $HOME/master.passwd
89
		grep "^bar:.*" $HOME/master.passwd
50
}
90
}
91
92
# Test modifying a user name with -l with option -N
93
atf_test_case user_mod_name_noupdate
94
user_mod_name_noupdate_body() {
95
	populate_etc_skel
96
97
	atf_check -s exit:0 ${PW} useradd foo
98
	atf_check -s exit:0 -o match:"^bar:.*" ${PW} usermod foo -l "bar" -N
99
	atf_check -s exit:0 -o match:"^foo:.*" \
100
		grep "^foo:.*" $HOME/master.passwd
101
}
102
51
atf_init_test_cases() {
103
atf_init_test_cases() {
52
	atf_add_test_case user_mod
104
	atf_add_test_case user_mod
105
	atf_add_test_case user_mod_noupdate
53
	atf_add_test_case user_mod_comments
106
	atf_add_test_case user_mod_comments
107
	atf_add_test_case user_mod_comments_noupdate
54
	atf_add_test_case user_mod_comments_invalid 
108
	atf_add_test_case user_mod_comments_invalid 
109
	atf_add_test_case user_mod_comments_invalid_noupdate 
55
	atf_add_test_case user_mod_name
110
	atf_add_test_case user_mod_name
111
	atf_add_test_case user_mod_name_noupdate
56
}
112
}

Return to bug 195865