Mercurial > hg > toybox
annotate tests/useradd.test @ 1766:190ecf70fbe5 draft
Fix an obvious typo in Makefile.
author | Elliott Hughes <enh@google.com> |
---|---|
date | Sat, 28 Mar 2015 13:13:42 -0500 |
parents | 23acd6af27e4 |
children |
rev | line source |
---|---|
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
1 #!/bin/bash |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
2 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com> |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
4 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com> |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
5 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
6 [ -f testing.sh ] && . testing.sh |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
7 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
8 if [ "$(id -u)" -ne 0 ] |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
9 then |
1711
23acd6af27e4
fix copy/paste-o in useradd.test
Elliott Hughes <enh@google.com>
parents:
1700
diff
changeset
|
10 echo "SKIPPED: useradd (not root)" |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
11 continue 2>/dev/null |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
12 exit |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
13 fi |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
14 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
15 # Redirecting all output to /dev/null for grep, adduser and deluser |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
16 arg="&>/dev/null" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
17 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
18 #testing "name" "command" "result" "infile" "stdin" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
19 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
20 # Default password for adding user is: 'password' |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
21 pass=`echo -ne 'password\npassword\n'` |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
22 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
23 user="toyTestUser" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
24 testing "adduser user_name (text)" "useradd $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
25 grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
26 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
27 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
28 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
29 user="toy1Test2User3" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
30 testing "adduser user_name (alphanumeric)" "useradd $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
31 grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
32 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
33 userdel -r $user $arg |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
34 |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
35 user="987654321" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
36 testing "adduser user_name (numeric)" "useradd $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
37 grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
38 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
39 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
40 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
41 user="toy.1Test-2User_3" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
42 testing "adduser user_name (with ./-/_)" "useradd $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
43 grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
44 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
45 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
46 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
47 # 70 characters long string; hereafter, we will use it as per our need. |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
48 user="abcdefghijklmnopqrstuvwxyz123456789abcdefghijklmnopqrstuvwxyz123456789" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
49 testing "adduser user_name (long string)" "useradd $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
50 grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
51 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
52 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
53 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
54 user="toyTestUser" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
55 testing "adduser user_name with dir" "useradd -h $PWD/dir $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
56 grep '^$user:.*dir' /etc/passwd $arg && [ -d $PWD/dir ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
57 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
58 userdel -r $user $arg |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
59 rm -rf $PWD/dir |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
60 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
61 gecos="aaa,bbb,ccc,ddd,eee" |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
62 testing "adduser user_name with gecos" "useradd -g '$gecos' $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
63 grep '^$user:.*$gecos' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
64 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
65 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
66 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
67 shl="/bin/sh" |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
68 testing "adduser user_name with shell" "useradd -s $shl $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
69 grep '^$user:.*$shl$' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
70 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
71 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
72 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
73 g_name="root" |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
74 g_id=`grep $g_name':.*:.*' /etc/group | cut -d : -f 3` |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
75 testing "adduser user_name with group" "useradd -G $g_name $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
76 grep '^$user:.*:.*:$g_id:.*' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
77 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
78 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
79 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
80 testing "adduser user_name (system user)" "useradd -S $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
81 grep '^$user:.*:.*:.*' /etc/passwd $arg && [ ! -e /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
82 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
83 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
84 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
85 testing "adduser user_name with -D" "useradd -D $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
86 grep '^$user:.*:.*:.*' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
87 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
88 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
89 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
90 testing "adduser user_name with -H" "useradd -H $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
91 grep '^$user:.*:.*:.*' /etc/passwd $arg && [ ! -e /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
92 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
93 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
94 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
95 testing "adduser user_name with dir and -H" "useradd -H -h $PWD/dir $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
96 grep '^$user:.*dir' /etc/passwd $arg && [ ! -e $PWD/dir ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
97 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
98 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
99 |
1700
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
100 testing "adduser user_name with user_id" "useradd -u 49999 $user $arg || |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
101 grep '^$user:x:49999:.*' /etc/passwd $arg && [ -d /home/$user ] && |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
102 echo 'yes'" "yes\n" "" "$pass" |
3b62d24bfa27
Separate 'userdel' from testing syntax.
Yeongdeok Suh <skyducks111@gmail.com>
parents:
1485
diff
changeset
|
103 userdel -r $user $arg |
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
104 |