Line 0
Link Here
|
|
|
1 |
# $FreeBSD$ |
2 |
|
3 |
# Import helper functions |
4 |
. $(atf_get_srcdir)/helper_functions.shin |
5 |
|
6 |
# Test mod user |
7 |
atf_test_case user_mod |
8 |
user_mod_body() { |
9 |
populate_etc_skel |
10 |
|
11 |
atf_check -s exit:67 -e match:"no such user" ${PW} usermod test |
12 |
atf_check -s exit:0 ${PW} useradd test |
13 |
atf_check -s exit:0 ${PW} usermod test |
14 |
atf_check -s exit:0 -o match:"^test:.*" \ |
15 |
grep "^test:.*" $HOME/master.passwd |
16 |
} |
17 |
|
18 |
# Test mod user with comments |
19 |
atf_test_case user_mod_comments |
20 |
user_mod_comments_body() { |
21 |
populate_etc_skel |
22 |
|
23 |
atf_check -s exit:0 ${PW} useradd test -c "Test User,home,123,456" |
24 |
atf_check -s exit:0 ${PW} usermod test -c "Test User,work,123,456" |
25 |
atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \ |
26 |
grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd |
27 |
} |
28 |
|
29 |
# Test mod user with invalid comments |
30 |
atf_test_case user_mod_comments_invalid |
31 |
user_mod_comments_invalid_body() { |
32 |
populate_etc_skel |
33 |
|
34 |
atf_check -s exit:0 ${PW} useradd test |
35 |
atf_check -s exit:65 -e match:"invalid character" \ |
36 |
${PW} usermod test -c "Test User,work,123:456,456" |
37 |
atf_check -s exit:1 -o empty \ |
38 |
grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd |
39 |
} |
40 |
|
41 |
# Test mod user name with -l |
42 |
atf_test_case user_mod_name |
43 |
user_mod_name_body() { |
44 |
populate_etc_skel |
45 |
|
46 |
atf_check -s exit:0 ${PW} useradd foo |
47 |
atf_check -s exit:0 ${PW} usermod foo -l "bar" |
48 |
atf_check -s exit:0 -o match:"^bar:.*" \ |
49 |
grep "^bar:.*" $HOME/master.passwd |
50 |
} |
51 |
atf_init_test_cases() { |
52 |
atf_add_test_case user_mod |
53 |
atf_add_test_case user_mod_comments |
54 |
atf_add_test_case user_mod_comments_invalid |
55 |
atf_add_test_case user_mod_name |
56 |
} |