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