]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pw/tests/pw_useradd.sh
Upgrade our copy of clang and llvm to 3.5.1 release. This is a bugfix
[FreeBSD/FreeBSD.git] / usr.sbin / pw / tests / pw_useradd.sh
1 # $FreeBSD$
2
3 # Import helper functions
4 . $(atf_get_srcdir)/helper_functions.shin
5
6 # Test add user
7 atf_test_case user_add
8 user_add_body() {
9         populate_etc_skel
10
11         atf_check -s exit:0 ${PW} useradd test
12         atf_check -s exit:0 -o match:"^test:.*" \
13                 grep "^test:.*" $HOME/master.passwd
14 }
15
16 # Test add user with option -N
17 atf_test_case user_add_noupdate
18 user_add_noupdate_body() {
19         populate_etc_skel
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
26 atf_test_case user_add_comments
27 user_add_comments_body() {
28         populate_etc_skel
29
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
33 }
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
46 atf_test_case user_add_comments_invalid
47 user_add_comments_invalid_body() {
48         populate_etc_skel
49
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
54 }
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
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
73 }