summaryrefslogtreecommitdiffstats
path: root/t/access.t
blob: c3f3341cd09ed0f50b218b32826a82c553192b3a (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/usr/bin/perl
use strict;
use warnings;

# this is hardcoded; change it if needed
use lib "src/lib";
use Gitolite::Test;

# test 'gitolite access'
# ----------------------------------------------------------------------

try "plan 254";

confreset;confadd '
    @admins     =   admin dev1
    repo gitolite-admin
        RW+     =   admin

    repo testing
        RW+     =   @all

    @g1 = t1
    repo @g1
        R       =   u2
        RW      =   u3
        RW+     =   u4
';

try "ADMIN_PUSH set1; !/FATAL/" or die text();

try "

    gitolite access -q t1 u1;   !ok;    !/./
    gitolite access -q t1 u1 R; !ok;    !/./
    gitolite access -q t1 u1 W; !ok;    !/./
    gitolite access -q t1 u1 +; !ok;    !/./
    gitolite access -q t1 u2;   !ok;    !/./
    gitolite access -q t1 u2 R; ok;     !/./
    gitolite access -q t1 u2 W; !ok;    !/./
    gitolite access -q t1 u2 +; !ok;    !/./
    gitolite access -q t1 u3;   !ok;    !/./
    gitolite access -q t1 u3 R; ok;     !/./
    gitolite access -q t1 u3 W; ok;     !/./
    gitolite access -q t1 u3 +; !ok;    !/./
    gitolite access -q t1 u4;   ok;     !/./
    gitolite access -q t1 u4 R; ok;     !/./
    gitolite access -q t1 u4 W; ok;     !/./
    gitolite access -q t1 u4 +; ok;     !/./

    gitolite access t1 u1;      !ok;    /\\+ any t1 u1 DENIED by fallthru/
    gitolite access t1 u1 R;    !ok;    /R any t1 u1 DENIED by fallthru/
    gitolite access t1 u1 W;    !ok;    /W any t1 u1 DENIED by fallthru/
    gitolite access t1 u1 +;    !ok;    /\\+ any t1 u1 DENIED by fallthru/
    gitolite access t1 u2;      !ok;    /\\+ any t1 u2 DENIED by fallthru/
    gitolite access t1 u2 R;    ok;     /refs/\.\*/
    gitolite access t1 u2 W;    !ok;    /W any t1 u2 DENIED by fallthru/
    gitolite access t1 u2 +;    !ok;    /\\+ any t1 u2 DENIED by fallthru/
    gitolite access t1 u3;      !ok;    /\\+ any t1 u3 DENIED by fallthru/
    gitolite access t1 u3 R;    ok;     /refs/\.\*/
    gitolite access t1 u3 W;    ok;     /refs/\.\*/
    gitolite access t1 u3 +;    !ok;    /\\+ any t1 u3 DENIED by fallthru/
    gitolite access t1 u4;      ok;     /refs/\.\*/
    gitolite access t1 u4 R;    ok;     /refs/\.\*/
    gitolite access t1 u4 W;    ok;     /refs/\.\*/
    gitolite access t1 u4 +;    ok;     /refs/\.\*/

";

confreset;confadd '
    @admins     =   admin dev1
    repo gitolite-admin
        RW+     =   admin

    @g1 = u1
    @g2 = u2
    @g3 = u3
    @gaa = aa
    repo @gaa
        RW+                 =   @g1
        RW                  =   @g2
        RW+     master      =   @g3
        RW      master      =   u4
        -       master      =   u5
        RW+     dev         =   u5
        RW                  =   u5
';

try "ADMIN_PUSH set2; !/FATAL/" or die text();

try "
    gitolite access \@gaa \@g1 + any ;                  ok;     /refs/.*/; !/DENIED/
    gitolite access aa \@g1 + refs/heads/master ;       ok;     /refs/.*/; !/DENIED/
    gitolite access \@gaa \@g1 + refs/heads/next ;      ok;     /refs/.*/; !/DENIED/
    gitolite access \@gaa \@g1 W refs/heads/next ;      ok;     /refs/.*/; !/DENIED/
    gitolite access \@gaa u1 + refs/heads/dev ;         ok;     /refs/.*/; !/DENIED/
    gitolite access \@gaa u1 + refs/heads/next ;        ok;     /refs/.*/; !/DENIED/
    gitolite access aa u1 W refs/heads/next ;           ok;     /refs/.*/; !/DENIED/
    gitolite access \@gaa \@g2 + refs/heads/master ;    !ok;    /\\+ refs/heads/master \@gaa \@g2 DENIED by fallthru/
    gitolite access \@gaa \@g2 + refs/heads/next ;      !ok;    /\\+ refs/heads/next \@gaa \@g2 DENIED by fallthru/
    gitolite access aa \@g2 W refs/heads/master ;       ok;     /refs/.*/; !/DENIED/
    gitolite access aa u2 + any ;                       !ok;    /\\+ any aa u2 DENIED by fallthru/
    gitolite access \@gaa u2 + refs/heads/master ;      !ok;    /\\+ refs/heads/master \@gaa u2 DENIED by fallthru/
    gitolite access \@gaa u2 W refs/heads/master ;      ok;     /refs/.*/; !/DENIED/
    gitolite access \@gaa \@g3 + refs/heads/master ;    ok;     /refs/heads/master/; !/DENIED/
    gitolite access \@gaa \@g3 W refs/heads/next ;      !ok;    /W refs/heads/next \@gaa \@g3 DENIED by fallthru/
    gitolite access \@gaa \@g3 W refs/heads/dev ;       !ok;    /W refs/heads/dev \@gaa \@g3 DENIED by fallthru/
    gitolite access aa u3 + refs/heads/dev ;            !ok;    /\\+ refs/heads/dev aa u3 DENIED by fallthru/
    gitolite access aa u3 + refs/heads/next ;           !ok;    /\\+ refs/heads/next aa u3 DENIED by fallthru/
    gitolite access \@gaa u4 + refs/heads/master ;      !ok;    /\\+ refs/heads/master \@gaa u4 DENIED by fallthru/
    gitolite access \@gaa u4 W refs/heads/master ;      ok;     /refs/heads/master/; !/DENIED/
    gitolite access aa u4 + refs/heads/next ;           !ok;    /\\+ refs/heads/next aa u4 DENIED by fallthru/
    gitolite access \@gaa u4 W refs/heads/next ;        !ok;    /W refs/heads/next \@gaa u4 DENIED by fallthru/
    gitolite access \@gaa u5 R any ;                    ok;     /refs/heads/dev/; !/DENIED/
    gitolite access aa u5 R any ;                       ok;     /refs/heads/dev/; !/DENIED/
    gitolite access \@gaa u5 + refs/heads/dev ;         ok;     /refs/heads/dev/; !/DENIED/
    gitolite access \@gaa u5 + refs/heads/master ;      !ok;    /\\+ refs/heads/master \@gaa u5 DENIED by refs/heads/master/
    gitolite access aa u5 + refs/heads/next ;           !ok;    /\\+ refs/heads/next aa u5 DENIED by fallthru/
    gitolite access \@gaa u5 R refs/heads/dev ;         ok;     /refs/heads/dev/; !/DENIED/
    gitolite access \@gaa u5 R refs/heads/master ;      !ok;    /R refs/heads/master \@gaa u5 DENIED by refs/heads/master/
    gitolite access \@gaa u5 R refs/heads/next ;        ok;     /refs/.*/; !/DENIED/
    gitolite access aa u5 W refs/heads/dev ;            ok;     /refs/heads/dev/; !/DENIED/
    gitolite access aa u5 W refs/heads/master ;         !ok;    /W refs/heads/master aa u5 DENIED by refs/heads/master/
    gitolite access \@gaa u5 W refs/heads/next ;        ok;     /refs/.*/; !/DENIED/
";

confreset;confadd '
    @admins     =   admin dev1
    repo gitolite-admin
        RW+     =   admin

    @gr1 = r1
    repo @gr1
        RW  refs/heads/v[0-9]   = u1
        RW  refs/heads          = tester

    @gr2 = r2
    repo @gr2
        RW  refs/heads/v[0-9]   = u1
        -   refs/heads/v[0-9]   = tester
        RW  refs/heads          = tester
';

try "ADMIN_PUSH set3; !/FATAL/" or die text();

try "
    gitolite access \@gr2 tester W refs/heads/v1;       !ok;    /W refs/heads/v1 \@gr2 tester DENIED by refs/heads/v\\[0-9\\]/
    gitolite access \@gr1 tester W refs/heads/v1;       ok;     /refs/heads/; !/DENIED/
    gitolite access r1 tester W refs/heads/v1;          ok;     /refs/heads/; !/DENIED/
    gitolite access r2 tester W refs/heads/v1;          !ok;    /W refs/heads/v1 r2 tester DENIED by refs/heads/v\\[0-9\\]/
    gitolite access r2 tester W refs/heads/va;          ok;     /refs/heads/; !/DENIED/
";

confreset;confadd '
    repo foo
        RW+ =   u1

    @gr1 = foo bar

    repo @gr1
        RW  =   u2
        R   =   u3

    repo @all
        R   =   gitweb

    repo c0
        RW+ =   @all
    repo c1
        RWC =   u1
        RW+ =   @all
';

try "ADMIN_PUSH set4; !/FATAL/" or die text();

try "
    gitolite access foo u1 +;           ok
    gitolite access foo u2 +;           !ok
    gitolite access foo u3 +;           !ok
    gitolite access foo u4 +;           !ok
    gitolite access foo gitweb +;       !ok

    gitolite access foo u1 W;           ok
    gitolite access foo u2 W;           ok
    gitolite access foo u3 W;           !ok
    gitolite access foo u4 W;           !ok
    gitolite access foo gitweb W;       !ok

    gitolite access foo u1 R;           ok
    gitolite access foo u2 R;           ok
    gitolite access foo u3 R;           ok
    gitolite access foo u4 R;           !ok
    gitolite access foo gitweb R;       ok

    gitolite access c0  u1 +;           ok
    gitolite access c0  u1 C;           ok
    gitolite access c0  u2 +;           ok
    gitolite access c0  u2 C;           ok
    gitolite access c1  u1 +;           ok
    gitolite access c1  u1 C;           ok
    gitolite access c1  u2 +;           ok
    gitolite access c1  u2 C;           !ok
";

confreset;confadd '
    repo foo
        R   =   u1
        RW  =   u2
        RW+ =   u3

    repo bar
        R   =   u1
        RW  =   u2
        RW+ =   u3
        RW+CDM  =   u6

';

try "ADMIN_PUSH set4; !/FATAL/" or die text();

try "
    gitolite access foo u1 +;           !ok
    gitolite access foo u2 +;           !ok
    gitolite access foo u3 +;           ok
    gitolite access foo u1 C;           !ok
    gitolite access foo u2 C;           ok
    gitolite access foo u3 C;           ok
    gitolite access foo u1 D;           !ok
    gitolite access foo u2 D;           !ok
    gitolite access foo u3 D;           ok
    gitolite access foo u1 M;           !ok
    gitolite access foo u2 M;           ok
    gitolite access foo u3 M;           ok

    gitolite access bar u1 +;           !ok
    gitolite access bar u2 +;           !ok
    gitolite access bar u3 +;           ok
    gitolite access bar u1 C;           !ok
    gitolite access bar u2 C;           !ok
    gitolite access bar u3 C;           !ok
    gitolite access bar u1 D;           !ok
    gitolite access bar u2 D;           !ok
    gitolite access bar u3 D;           !ok
    gitolite access bar u1 M;           !ok
    gitolite access bar u2 M;           !ok
    gitolite access bar u3 M;           !ok

    gitolite access bar u6 R;           ok
    gitolite access bar u6 W;           ok
    gitolite access bar u6 +;           ok
    gitolite access bar u6 C;           ok
    gitolite access bar u6 D;           ok
    gitolite access bar u6 M;           ok
";