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