added admin tests
|
1 |
use Test::More 'no_plan'; |
add change description test
|
2 |
use strict; |
3 |
use warnings; |
|
added admin tests
|
4 | |
5 |
use FindBin; |
|
6 |
use utf8; |
|
7 |
use lib "$FindBin::Bin/../lib"; |
|
8 |
use lib "$FindBin::Bin/../extlib/lib/perl5"; |
|
add create repository tests
|
9 |
use File::Path 'rmtree'; |
added admin tests
|
10 |
use Encode qw/encode decode/; |
11 | ||
12 |
use Test::Mojo; |
|
13 | ||
14 |
# Test DB |
|
rename admin.t to user.t
|
15 |
my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/user.db"; |
added admin tests
|
16 | |
17 |
# Test Repository home |
|
rename admin.t to user.t
|
18 |
my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/user"; |
added admin tests
|
19 | |
add need_login_always_option
|
20 |
$ENV{GITPREP_NO_MYCONFIG} = 1; |
21 | ||
added admin tests
|
22 |
use Gitprep; |
23 | ||
added admin page tests
|
24 |
note 'Start page'; |
added admin tests
|
25 |
{ |
added _start page tests
|
26 |
unlink $db_file; |
27 | ||
28 |
my $app = Gitprep->new; |
|
29 |
my $t = Test::Mojo->new($app); |
|
30 |
$t->ua->max_redirects(3); |
|
add import branch tests
|
31 |
|
added admin tests
|
32 |
# Redirect to _start page |
cleanup
|
33 |
$t->get_ok('/'); |
34 |
$t->content_like(qr/Create Admin User/); |
|
added admin tests
|
35 | |
36 |
# Page access |
|
cleanup
|
37 |
$t->get_ok('/_start'); |
38 |
$t->content_like(qr/Create Admin User/); |
|
added admin tests
|
39 |
|
40 |
# Password is empty |
|
cleanup
|
41 |
$t->post_ok('/_start?op=create', form => {password => ''}); |
42 |
$t->content_like(qr/Password is empty/); |
|
added _start page tests
|
43 |
|
44 |
# Password contains invalid character |
|
cleanup
|
45 |
$t->post_ok('/_start?op=create', form => {password => "\t"}); |
46 |
$t->content_like(qr/Password contains invalid character/); |
|
added _start page tests
|
47 | |
48 |
# Two password don't match |
|
cleanup
|
49 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'b'}); |
50 |
$t->content_like(qr/Two password/); |
|
added _start page tests
|
51 |
|
52 |
# Create admin user |
|
cleanup
|
53 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
add need_login_always_option
|
54 |
$t->content_like(qr/Login page/); |
added _start page tests
|
55 | |
Can't access _start page aft...
|
56 |
# Admin user already exists(Redirect to top page) |
cleanup
|
57 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
Can't access _start page aft...
|
58 |
$t->content_like(qr/Users/); |
added admin page tests
|
59 |
} |
60 | ||
add reset password test
|
61 |
note 'Admin pages'; |
added admin page tests
|
62 |
{ |
63 |
unlink $db_file; |
|
64 | ||
65 |
my $app = Gitprep->new; |
|
66 |
my $t = Test::Mojo->new($app); |
|
67 |
$t->ua->max_redirects(3); |
|
68 | ||
69 |
# Create admin user |
|
cleanup
|
70 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
add need_login_always_option
|
71 |
$t->content_like(qr/Login page/); |
added admin page tests
|
72 |
|
73 |
# Page access |
|
cleanup
|
74 |
$t->get_ok('/_login'); |
add need_login_always_option
|
75 |
$t->content_like(qr/Login page/); |
added admin page tests
|
76 |
|
77 |
# Login fail |
|
cleanup
|
78 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'b'}); |
79 |
$t->content_like(qr/User name or password is wrong/); |
|
added admin page tests
|
80 | |
81 |
# Login success |
|
cleanup
|
82 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'}); |
83 |
$t->content_like(qr/Admin/); |
|
added admin page tests
|
84 |
|
85 |
note 'Admin page'; |
|
86 |
{ |
|
cleanup
|
87 |
$t->post_ok('/_admin'); |
88 |
$t->content_like(qr/Admin/); |
|
added admin page tests
|
89 |
} |
90 |
|
|
91 |
note 'Admin User page'; |
|
92 |
{ |
|
cleanup
|
93 |
$t->get_ok('/_admin/users'); |
94 |
$t->content_like(qr/Admin Users/); |
|
added admin page tests
|
95 |
} |
added _start page tests
|
96 | |
added admin page tests
|
97 |
note 'Create User page'; |
98 |
{ |
|
added admin user tests
|
99 |
# Page access |
cleanup
|
100 |
$t->get_ok('/_admin/user/create'); |
101 |
$t->content_like(qr/Create User/); |
|
added admin user tests
|
102 |
|
103 |
# User name is empty |
|
cleanup
|
104 |
$t->post_ok('/_admin/user/create?op=create', form => {id => ''}); |
105 |
$t->content_like(qr/User name is empty/); |
|
added admin user tests
|
106 | |
107 |
# User name contain invalid character |
|
cleanup
|
108 |
$t->post_ok('/_admin/user/create?op=create', form => {id => '&'}); |
109 |
$t->content_like(qr/User name contain invalid character/); |
|
added admin user tests
|
110 | |
111 |
# User name is too long |
|
cleanup
|
112 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'a' x 21}); |
113 |
$t->content_like(qr/User name is too long/); |
|
added admin user tests
|
114 | |
115 |
# Password is empty |
|
cleanup
|
116 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'a', password => ''}); |
117 |
$t->content_like(qr/Password is empty/); |
|
added admin user tests
|
118 | |
119 |
# Password contain invalid character |
|
cleanup
|
120 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'a', password => "\t"}); |
121 |
$t->content_like(qr/Password contain invalid character/); |
|
added admin user tests
|
122 | |
123 |
# Password contain invalid character |
|
cleanup
|
124 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'a', password => 'a', password2 => 'b'}); |
125 |
$t->content_like(qr/Two password/); |
|
added admin user tests
|
126 |
|
127 |
# Create user |
|
cleanup
|
128 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'}); |
129 |
$t->content_like(qr/Success.*created/); |
|
added tests and move delete ...
|
130 |
} |
131 |
|
|
132 |
note 'Admin Users page'; |
|
cleanup
|
133 |
$t->get_ok('/_admin/users'); |
134 |
$t->content_like(qr/Admin Users/); |
|
135 |
$t->content_like(qr/kimoto/); |
|
added tests and move delete ...
|
136 |
|
137 |
note 'Reset password page'; |
|
138 |
{ |
|
139 |
# Page access |
|
cleanup
|
140 |
$t->get_ok('/reset-password?user=kimoto'); |
141 |
$t->content_like(qr/Reset Password/); |
|
142 |
$t->content_like(qr/kimoto/); |
|
added tests and move delete ...
|
143 |
|
144 |
# Password is empty |
|
cleanup
|
145 |
$t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => ''}); |
146 |
$t->content_like(qr/Password is empty/); |
|
added tests and move delete ...
|
147 | |
148 |
# Password contains invalid character |
|
cleanup
|
149 |
$t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => "\t"}); |
150 |
$t->content_like(qr/Password contains invalid character/); |
|
added tests and move delete ...
|
151 |
|
152 |
# Two password don't match |
|
cleanup
|
153 |
$t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => 'a', password2 => 'b'}); |
154 |
$t->content_like(qr/Two password/); |
|
added tests and move delete ...
|
155 | |
156 |
# Reset password |
|
cleanup
|
157 |
$t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => 'a', password2 => 'a'}); |
158 |
$t->content_like(qr/Success.*changed/); |
|
added delete user test
|
159 |
} |
160 | ||
161 |
note 'Delete user'; |
|
162 |
{ |
|
163 |
# Create user |
|
cleanup
|
164 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto-tmp', password => 'a', password2 => 'a'}); |
165 |
$t->content_like(qr/kimoto-tmp/); |
|
166 |
$t->get_ok('/_admin/users'); |
|
167 |
$t->content_like(qr/kimoto-tmp/); |
|
added delete user test
|
168 | |
169 |
# User not exists |
|
cleanup
|
170 |
$t->post_ok('/_admin/users?op=delete', form => {user => 'kimoto-notting'}); |
171 |
$t->content_like(qr/Internal/); |
|
added delete user test
|
172 | |
173 |
# User not exists |
|
cleanup
|
174 |
$t->post_ok('/_admin/users?op=delete', form => {user => 'kimoto-tmp'}); |
175 |
$t->content_like(qr/User.*deleted/); |
|
176 |
$t->get_ok('/_admin/users'); |
|
177 |
$t->content_unlike(qr/kimoto-tmp/); |
|
added admin page tests
|
178 |
} |
add reset password test
|
179 |
|
180 |
note 'logout'; |
|
cleanup
|
181 |
$t->get_ok('/_logout'); |
182 |
$t->get_ok('/_admin'); |
|
183 |
$t->content_like(qr/Users/); |
|
add reset password test
|
184 |
} |
185 | ||
186 |
note 'Reset password'; |
|
187 |
{ |
|
188 |
unlink $db_file; |
|
189 | ||
190 |
my $app = Gitprep->new; |
|
191 |
my $t = Test::Mojo->new($app); |
|
192 |
$t->ua->max_redirects(3); |
|
193 | ||
194 |
# Create admin user |
|
cleanup
|
195 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
add need_login_always_option
|
196 |
$t->content_like(qr/Login page/);; |
add reset password test
|
197 | |
198 |
# Not loing user can't access |
|
cleanup
|
199 |
$t->get_ok('/reset-password'); |
200 |
$t->content_like(qr/Users/); |
|
add reset password test
|
201 | |
202 |
# Cnahge password(reset_password conf on) |
|
203 |
$app->config->{admin}{reset_password} = 1; |
|
cleanup
|
204 |
$t->get_ok('/reset-password'); |
205 |
$t->content_like(qr/Reset Password/); |
|
206 |
$t->post_ok('/reset-password?op=reset', form => {password => 'b', password2 => 'b'}); |
|
207 |
$t->content_like(qr/Success.*changed/); |
|
add reset password test
|
208 |
$app->config->{admin}{reset_password} = 0; |
209 | ||
210 |
# Login success |
|
cleanup
|
211 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'b'}); |
212 |
$t->content_like(qr/Admin/); |
|
add reset password test
|
213 |
|
214 |
# Create user |
|
cleanup
|
215 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', password => 'a', password2 => 'a'}); |
216 |
$t->content_like(qr/kimoto1/); |
|
217 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'}); |
|
218 |
$t->content_like(qr/kimoto2/); |
|
add reset password test
|
219 |
|
220 |
# Logout |
|
221 |
$t->get_ok('/_logout'); |
|
222 |
|
|
223 |
# Login as kimoto |
|
224 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'}); |
|
225 |
$t->get_ok('/')->content_like(qr/kimoto1/); |
|
226 | ||
227 |
# Don't change other user password |
|
cleanup
|
228 |
$t->get_ok('/reset-password?user=kimoto2'); |
229 |
$t->content_like(qr/Users/); |
|
230 |
$t->post_ok('/reset-password?user=kimoto2&op=reset', form => {password => 'b', password2 => 'b'}); |
|
231 |
$t->content_like(qr/Users/); |
|
add reset password test
|
232 | |
233 |
# Reset password |
|
cleanup
|
234 |
$t->get_ok('/reset-password?user=kimoto1'); |
235 |
$t->content_like(qr/Reset Password/); |
|
add reset password test
|
236 |
$t->post_ok('/reset-password?user=kimoto1&op=reset', form => {password => 'b', password2 => 'b'}); |
237 |
|
|
238 |
# Login as kimoto |
|
239 |
$t->get_ok('/_logout'); |
|
240 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'b'}); |
|
241 |
$t->get_ok('/')->content_like(qr/kimoto1/); |
|
added admin tests
|
242 |
} |
add create repository tests
|
243 | |
add title
|
244 |
note 'Profile'; |
add create repository tests
|
245 |
{ |
246 |
unlink $db_file; |
|
247 |
rmtree $rep_home; |
|
248 | ||
249 |
my $app = Gitprep->new; |
|
250 |
my $t = Test::Mojo->new($app); |
|
251 |
$t->ua->max_redirects(3); |
|
252 | ||
253 |
# Create admin user |
|
cleanup
|
254 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
add need_login_always_option
|
255 |
$t->content_like(qr/Login page/); |
add create repository tests
|
256 | |
257 |
# Login as admin |
|
258 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'}); |
|
259 | ||
260 |
# Create user |
|
cleanup
|
261 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', password => 'a', password2 => 'a'}); |
262 |
$t->content_like(qr/kimoto1/); |
|
263 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'}); |
|
264 |
$t->content_like(qr/kimoto2/); |
|
add create repository tests
|
265 |
|
266 |
# Login as kimoto1 |
|
267 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'}); |
|
268 | ||
add title
|
269 |
# Profile |
cleanup
|
270 |
$t->get_ok('/kimoto1/_settings'); |
add title
|
271 |
$t->content_like(qr/Profile/); |
add create repository tests
|
272 |
|
273 |
# Other user can't access |
|
cleanup
|
274 |
$t->get_ok('/kimoto2/_settings'); |
275 |
$t->content_like(qr/Users/); |
|
add create repository tests
|
276 |
|
277 |
note 'Create repository'; |
|
278 |
{ |
|
279 |
# Create repository page |
|
cleanup
|
280 |
$t->get_ok('/_new'); |
281 |
$t->content_like(qr/Create repository/); |
|
add create repository tests
|
282 |
|
283 |
# Not logined user can't access |
|
284 |
$t->get_ok('/_logout'); |
|
cleanup
|
285 |
$t->get_ok('/_new'); |
286 |
$t->content_like(qr/Users/); |
|
add create repository tests
|
287 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'}); |
288 |
|
|
289 |
# Create repository |
|
cleanup
|
290 |
$t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello'}); |
291 |
$t->content_like(qr/Create a new repository on the command line/); |
|
292 |
$t->content_like(qr/t1\.git/); |
|
293 |
$t->content_like(qr/Hello/); |
|
add git export file test
|
294 |
ok(-f "$rep_home/kimoto1/t1.git/git-daemon-export-ok"); |
295 |
ok(-f "$rep_home/kimoto1/t1.git/hooks/post-update"); |
|
add create repository tests
|
296 | |
fix bug that forst . is not ...
|
297 |
# Create repository(first character is .) |
298 |
$t->post_ok('/_new?op=create', form => {project => '.dot', description => 'Dot'}); |
|
299 |
$t->content_like(qr/Create a new repository on the command line/); |
|
300 |
$t->content_like(qr/\.dot\.git/); |
|
301 |
$t->content_like(qr/Dot/); |
|
302 | ||
add create repository tests
|
303 |
# Create repository(with readme) |
cleanup
|
304 |
$t->post_ok('/_new?op=create', form => {project => 't2', description => 'Hello', readme => 1}); |
305 |
$t->content_like(qr/first commit/); |
|
306 |
$t->content_like(qr/t2\.git/); |
|
default readme file is chang...
|
307 |
$t->content_like(qr/README\.md/); |
safe first commit with READM...
|
308 |
$t->content_like(qr/kimoto1\@localhost/); |
version up and add descripti...
|
309 |
$t->content_like(qr/Hello/); |
add rename project and suppr...
|
310 | |
simplify rename project
|
311 |
# Settings page(don't has README) |
cleanup
|
312 |
$t->get_ok('/kimoto1/t1/settings'); |
313 |
$t->content_like(qr/Settings/); |
|
add rename project and suppr...
|
314 | |
simplify rename project
|
315 |
# Settings page(has README) |
cleanup
|
316 |
$t->get_ok('/kimoto1/t2/settings'); |
317 |
$t->content_like(qr/Settings/); |
|
add private checkbox to new ...
|
318 | |
319 |
# Create repository(with private) |
|
320 |
$t->post_ok('/_new?op=create', form => {project => 't_private', private => 1}); |
|
321 |
$t->content_like(qr/t_private\.git/); |
|
322 |
$t->content_like(qr/icon-lock/); |
|
add create repository tests
|
323 |
} |
cleanup
|
324 |
|
325 |
note 'Project settings'; |
|
add rename project and suppr...
|
326 |
{ |
327 |
note 'Rename project'; |
|
328 |
{ |
|
329 |
# Empty |
|
330 |
$t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {}); |
|
331 |
$t->content_like(qr/Repository name is empty/); |
|
332 |
|
|
333 |
# Invalid character |
|
334 |
$t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {'to-project' => '&'}); |
|
335 |
$t->content_like(qr/Repository name contains invalid charactor/); |
|
336 |
|
|
337 |
# Rename project |
|
338 |
$t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {'to-project' => 't3'}); |
|
339 |
$t->content_like(qr/Repository name is renamed to t3/); |
|
add change description test
|
340 |
$t->post_ok('/kimoto1/t3/settings?op=rename-project', form => {'to-project' => 't2'}); |
341 |
$t->content_like(qr/Repository name is renamed to t2/); |
|
342 |
} |
|
343 |
|
|
344 |
note 'Change description'; |
|
345 |
{ |
|
fix description file not cop...
|
346 |
# Change description(t1) |
add change description test
|
347 |
$t->post_ok("/kimoto1/t1/settings?op=change-description", form => {description => 'あああ'}); |
348 |
$t->content_like(qr/Description is saved/); |
|
add default branch test
|
349 |
$t->content_like(qr/あああ/); |
fix description file not cop...
|
350 | |
351 |
# Change description(t2) |
|
352 |
$t->post_ok("/kimoto1/t2/settings?op=change-description", form => {description => 'いいい'}); |
|
353 |
$t->content_like(qr/Description is saved/); |
|
354 |
$t->content_like(qr/いいい/); |
|
add default branch test
|
355 |
} |
356 |
|
|
357 |
note 'Change default branch'; |
|
358 |
{ |
|
359 |
# Default branch default |
|
360 |
$t->get_ok('/kimoto1/t1/settings'); |
|
361 |
$t->content_like(qr/master/); |
|
362 |
|
|
363 |
# Change default branch |
|
364 |
my $cmd = "git --git-dir=$rep_home/kimoto1/t2.git branch b1"; |
|
365 |
system($cmd) == 0 or die "Can't execute git branch"; |
|
366 |
$t->get_ok('/kimoto1/t2/settings'); |
|
367 |
$t->content_like(qr/b1/); |
|
368 |
$t->post_ok("/kimoto1/t2/settings?op=default-branch", form => {'default-branch' => 'b1'}); |
|
369 |
$t->content_like(qr/Default branch is changed to b1/); |
|
add rename project and suppr...
|
370 |
} |
add delete project test
|
371 |
|
372 |
note 'Delete project'; |
|
373 |
{ |
|
add fork test
|
374 |
$t->post_ok('/kimoto1/t1/settings?op=delete-project'); |
375 |
$t->content_like(qr/Repository t1 is deleted/); |
|
add delete project test
|
376 |
$t->get_ok('/kimoto1'); |
add fork test
|
377 |
$t->content_unlike(qr/t1/); |
add delete project test
|
378 |
} |
add rename project and suppr...
|
379 |
} |
add create repository tests
|
380 |
} |
add fork test
|
381 | |
382 |
note 'fork'; |
|
383 |
{ |
|
384 |
my $app = Gitprep->new; |
|
385 |
my $t = Test::Mojo->new($app); |
|
386 |
$t->ua->max_redirects(3); |
|
387 |
|
|
388 |
# Don't logind |
|
389 |
$t->get_ok("/kimoto1/t2/fork"); |
|
390 |
$t->content_like(qr/Users/); |
|
391 | ||
392 |
# Login as kimoto2 |
|
393 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'}); |
|
394 |
|
|
395 |
# Fork kimoto1/t2 |
|
396 |
$t->get_ok("/kimoto1/t2/fork"); |
|
397 |
$t->content_like(qr#Repository is forked from /kimoto1/t2#); |
|
fix description file not cop...
|
398 |
$t->content_like(qr/いいい/); |
add fork test
|
399 |
|
400 |
# Fork kimoto1/t2 again |
|
401 |
$t->get_ok("/kimoto1/t2/fork"); |
|
402 |
$t->content_like(qr/forked from/); |
|
403 |
$t->content_like(qr#kimoto1/t2#); |
|
404 |
$t->content_unlike(qr/Repository is forked from/); |
|
405 |
} |
|
fix branch not deleted bug a...
|
406 | |
add network test
|
407 |
note 'Network'; |
408 |
{ |
|
409 |
my $app = Gitprep->new; |
|
410 |
my $t = Test::Mojo->new($app); |
|
411 |
$t->ua->max_redirects(3); |
|
412 | ||
413 |
$t->get_ok("/kimoto1/t2/network"); |
|
414 |
$t->content_like(qr/Members of the t2/); |
|
415 |
$t->content_like(qr/My branch.*kimoto1.*t2.*master/s); |
|
416 |
$t->content_like(qr/Member branch.*kimoto2.*t2.*master/s); |
|
417 |
|
|
418 |
note 'Graph'; |
|
419 |
{ |
|
420 |
$t->get_ok("/kimoto1/t2/network/graph/master...kimoto2/t2/master"); |
|
421 |
$t->content_like(qr/Graph/); |
|
422 |
$t->content_like(qr/first commit/); |
|
423 |
} |
|
424 |
} |
|
425 | ||
fix branch not deleted bug a...
|
426 |
note 'Delete branch'; |
427 |
{ |
|
428 |
my $app = Gitprep->new; |
|
429 |
my $t = Test::Mojo->new($app); |
|
430 |
$t->ua->max_redirects(3); |
|
431 |
|
|
432 |
# No delete branch button |
|
433 |
$t->get_ok("/kimoto1/t2/branches"); |
|
434 |
$t->content_like(qr/Branches/); |
|
435 |
$t->content_unlike(qr/Delete branch/); |
|
add test
|
436 |
|
437 |
# Can't delete branch when no login |
|
438 |
$t->post_ok('/kimoto1/t2/branches?op=delete', form => {branch => 'tmp_branch'}) |
|
439 |
->content_like(qr/Users/); |
|
440 |
|
|
fix branch not deleted bug a...
|
441 | |
442 |
# Login as kimoto1 |
|
443 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'}); |
|
444 |
my $cmd = "git --git-dir=$rep_home/kimoto1/t2.git branch tmp_branch"; |
|
445 |
system($cmd) == 0 or die "Can't execute git branch"; |
|
446 |
$t->get_ok("/kimoto1/t2/branches"); |
|
improve branch design
|
447 |
$t->content_like(qr/Delete/); |
fix branch not deleted bug a...
|
448 |
$t->content_like(qr/tmp_branch/); |
449 |
|
|
450 |
# Delete branch |
|
451 |
$t->post_ok('/kimoto1/t2/branches?op=delete', form => {branch => 'tmp_branch'}); |
|
452 |
$t->content_like(qr/Branch tmp_branch is deleted/); |
|
453 |
$t->get_ok('/kimoto1/t2/branches'); |
|
454 |
$t->content_unlike(qr/tmp_branch/); |
|
455 |
} |
|
add import-branch authentica...
|
456 | |
457 |
note 'import-branch'; |
|
458 |
{ |
|
459 |
my $app = Gitprep->new; |
|
460 |
my $t = Test::Mojo->new($app); |
|
461 |
$t->ua->max_redirects(3); |
|
462 | ||
add import branch tests
|
463 |
# Login as kimoto1 |
464 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'}); |
|
465 |
$t->get_ok('/')->content_like(qr/Logined as kimoto1 /); |
|
add import-branch authentica...
|
466 | |
467 |
# Create project |
|
add import branch tests
|
468 |
$t->post_ok('/_new?op=create', form => {project => 'import-branch1', description => '', readme => 1}); |
469 |
$t->get_ok('/kimoto1')->content_like(qr/import-branch1/); |
|
add import-branch authentica...
|
470 |
|
add import branch tests
|
471 |
# Login as kimoto2 |
472 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'}); |
|
473 |
$t->get_ok('/')->content_like(qr/Logined as kimoto2 /); |
|
474 | ||
475 |
# Fork kimoto1/import-branch1 |
|
476 |
$t->get_ok("/kimoto1/import-branch1/fork"); |
|
477 |
$t->content_like(qr#Repository is forked from /kimoto1/import-branch1#); |
|
478 | ||
479 |
# Access not valid user |
|
480 |
$t->get_ok('/kimoto1/import-branch1/network'); |
|
481 |
$t->content_like(qr/Network/); |
|
482 |
$t->content_unlike(qr/Import/); |
|
483 |
$t->get_ok('/kimoto1/import-branch1/import-branch/kimoto2/import-branch1?remote-branch=master'); |
|
484 |
$t->content_like(qr/ Index page /); |
|
485 |
|
|
486 |
# Show network page import button |
|
487 |
$t->get_ok('/kimoto2/import-branch1/network'); |
|
488 |
$t->content_like(qr/Network/); |
|
489 |
$t->content_like(qr/Import/); |
|
490 |
|
|
491 |
# Import branch page access |
|
492 |
$t->get_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?remote-branch=master'); |
|
493 |
$t->content_like(qr/Import branch/); |
|
494 | ||
495 |
# Invalid parameters |
|
496 |
$t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?remote-branch=master&op=import'); |
|
497 |
$t->content_like(qr/Branch name is empty/); |
|
add import-branch authentica...
|
498 |
|
add import branch tests
|
499 |
# Import branch |
500 |
$t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?op=import', form => { |
|
501 |
branch => 'new1', |
|
502 |
'remote-branch' => 'master' |
|
503 |
}); |
|
504 |
$t->content_like(qr#Success: import#); |
|
505 |
$t->get_ok('/kimoto2/import-branch1/branches')->content_like(qr/new1/); |
|
506 | ||
507 |
# Import same name branch fail |
|
508 |
$t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?op=import', form => { |
|
509 |
branch => 'new1', |
|
510 |
'remote-branch' => 'master' |
|
511 |
}); |
|
512 |
$t->content_like(qr#already exists#); |
|
513 | ||
514 |
# Import force |
|
515 |
$t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?op=import', form => { |
|
516 |
branch => 'new1', |
|
517 |
'remote-branch' => 'master', |
|
518 |
force => 1 |
|
519 |
}); |
|
520 |
$t->content_like(qr#Success: force import#); |
|
add import-branch authentica...
|
521 |
} |
add private repository and c...
|
522 | |
523 |
note 'Private repository and collaborator'; |
|
524 |
{ |
|
525 |
unlink $db_file; |
|
526 |
rmtree $rep_home; |
|
527 | ||
528 |
my $app = Gitprep->new; |
|
529 |
my $t = Test::Mojo->new($app); |
|
530 |
$t->ua->max_redirects(3); |
|
531 | ||
532 |
# Create admin user |
|
533 |
$t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}); |
|
534 |
$t->content_like(qr/Login page/); |
|
535 | ||
536 |
# Login success |
|
537 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'}); |
|
538 |
$t->content_like(qr/Admin/); |
|
539 |
|
|
540 |
# Create user |
|
541 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'}); |
|
542 |
$t->content_like(qr/Success.*created/); |
|
543 |
$t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'}); |
|
544 |
$t->content_like(qr/Success.*created/); |
|
545 | ||
546 |
# Login as kimoto |
|
547 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'}); |
|
548 |
$t->get_ok('/')->content_like(qr/kimoto/); |
|
549 | ||
550 |
# Create repository |
|
551 |
$t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1}); |
|
552 |
$t->content_like(qr/README/); |
|
553 |
|
|
554 |
# Check private repository |
|
555 |
$t->post_ok("/kimoto/t1/settings?op=private", form => {private => 1}); |
|
556 |
$t->content_like(qr/Repository is private/); |
|
557 |
|
|
558 |
# Can access repository myself |
|
559 |
$t->get_ok("/kimoto/t1"); |
|
560 |
$t->content_like(qr/README/); |
|
561 | ||
562 |
# Login as kimoto2 |
|
563 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'}); |
|
564 |
$t->get_ok('/')->content_like(qr/kimoto2/); |
|
565 |
|
|
566 |
# Can't access private repository |
|
567 |
$t->get_ok("/kimoto/t1"); |
|
568 |
$t->content_like(qr/t1 is private repository/); |
|
569 |
|
|
570 |
# Login as kimoto |
|
571 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'}); |
|
572 |
$t->get_ok('/')->content_like(qr/kimoto/); |
|
573 |
|
|
574 |
# Add collaborator |
|
575 |
$t->post_ok("/kimoto/t1/settings/collaboration?op=add", form => {collaborator => 'kimoto2'}); |
|
576 |
$t->content_like(qr/Collaborator kimoto2 is added/); |
|
577 |
|
|
578 |
# Login as kimoto2 |
|
579 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'}); |
|
580 |
$t->get_ok('/')->content_like(qr/kimoto2/); |
|
581 |
|
|
582 |
# Can access private repository from collaborator |
|
583 |
$t->get_ok("/kimoto/t1"); |
|
584 |
$t->content_like(qr/README/); |
|
585 | ||
586 |
# Login as kimoto |
|
587 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'}); |
|
588 |
$t->get_ok('/')->content_like(qr/kimoto/); |
|
589 | ||
590 |
# Delete collaborator |
|
591 |
$t->post_ok("/kimoto/t1/settings/collaboration?op=remove", form => {collaborator => 'kimoto2'}); |
|
592 |
$t->content_like(qr/Collaborator kimoto2 is removed/); |
|
593 | ||
594 |
# Login as kimoto2 |
|
595 |
$t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'}); |
|
596 |
$t->get_ok('/')->content_like(qr/kimoto2/); |
|
597 | ||
598 |
# Can't access private repository |
|
599 |
$t->get_ok("/kimoto/t1"); |
|
600 |
$t->content_like(qr/t1 is private repository/); |
|
601 |
} |