blob: 3e5bf39352be90a14f3751db0fd38528b4c087b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
init_tests \
setup_user_usage \
setup_user_fullname \
setup_user_interactive_no \
setup_user_interactive \
setup_user_interactive_fullname \
setup_user_interactive_singlename \
setup_user_interactive_suggest_ssh \
setup_user_groups_commas \
setup_user_groups_spaces \
setup_user_admin
setup_user_usage_body() {
test_usage setup-user
}
setup_user_body() {
init_env
atf_check -s exit:0 \
-o match:"adduser -D testuser" \
-e empty \
setup-user testuser
}
setup_user_fullname_body() {
init_env
atf_check -s exit:0 \
-o match:"adduser.* -D .*testuser" \
-o match:"adduser.* -g Joe User .*testuser" \
-e empty \
setup-user -f "Joe User" testuser
}
setup_user_interactive_no_body() {
init_env
echo "no" >answers
atf_check -s exit:0 \
-o match:"Setup a user" \
-o not-match:"adduser.*" \
-e empty \
setup-user <answers
}
setup_user_interactive_body() {
init_env
(
echo "testuser"
echo "Joe User"
echo "none"
) >answers
atf_check -s exit:0 \
-o match:"Setup a user" \
-o match:"Full name for user testuser" \
-o not-match:"adduser.* -D .*testuser" \
-o match:"adduser.* -g Joe User .*testuser" \
-e empty \
setup-user <answers
}
setup_user_interactive_fullname_body() {
init_env
echo "" >answers
atf_check -s exit:0 \
-o match:"Setup a user.*\[juser\]" \
-o not-match:"Full name for user juser" \
-o not-match:"adduser.* -D .*" \
-o match:"adduser.* -g Joe User .*juser" \
-e empty \
setup-user -f "Joe User" -k none <answers
}
setup_user_interactive_singlename_body() {
init_env
echo "" >answers
atf_check -s exit:0 \
-o match:"Setup a user.*\[joe\]" \
-o not-match:"Full name for user" \
-o not-match:"adduser.* -D .*" \
-o match:"adduser.* -g Joe .*joe" \
-e empty \
setup-user -f "Joe" -k none <answers
}
setup_user_interactive_suggest_ssh_body() {
init_env
( echo "testuser"
echo "FullName"
echo "al"
echo ""
)>answers
export WGETCONTENT='ssh-id from alpine'
atf_check -s exit:0 \
-o match:"Setup a user" \
-o match:"Full name for user" \
-o match:"Enter ssh key.*none" \
-o match:"Enter ssh key.*gitlab.alpinelinux.org.*testuser.keys" \
-o match:"adduser.* -g FullName .*testuser" \
-e empty \
setup-user <answers
grep "$WGETCONTENT" home/testuser/.ssh/authorized_keys \
|| atf_fail "ssh key not fetched from alpinelinux"
}
setup_user_groups_commas_body() {
init_env
atf_check -s exit:0 \
-o match:"addgroup testuser wheel" \
-o match:"addgroup testuser audio" \
-o match:"addgroup testuser video" \
-e empty \
setup-user -g wheel,audio,video testuser
}
setup_user_groups_spaces_body() {
init_env
atf_check -s exit:0 \
-o match:"addgroup testuser wheel" \
-o match:"addgroup testuser audio" \
-o match:"addgroup testuser video" \
-e empty \
setup-user -g "wheel audio video" testuser
}
setup_user_admin_body() {
init_env
atf_check -s exit:0 \
-o match:"addgroup testuser wheel" \
-e empty \
setup-user -a testuser
grep wheel etc/doas.d/doas.conf
}
|