gitprep / xt / user.t /
Newer Older
620 lines | 19.881kb
added admin tests
Yuki Kimoto authored on 2013-05-16
1
use Test::More 'no_plan';
add change description test
Yuki Kimoto authored on 2013-05-25
2
use strict;
3
use warnings;
added admin tests
Yuki Kimoto authored on 2013-05-16
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
Yuki Kimoto authored on 2013-05-19
9
use File::Path 'rmtree';
added admin tests
Yuki Kimoto authored on 2013-05-16
10
use Encode qw/encode decode/;
11

            
12
use Test::Mojo;
13

            
14
# Test DB
rename admin.t to user.t
Yuki Kimoto authored on 2013-05-24
15
my $db_file = $ENV{GITPREP_DB_FILE} = "$FindBin::Bin/user.db";
added admin tests
Yuki Kimoto authored on 2013-05-16
16

            
17
# Test Repository home
rename admin.t to user.t
Yuki Kimoto authored on 2013-05-24
18
my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/user";
added admin tests
Yuki Kimoto authored on 2013-05-16
19

            
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
20
$ENV{GITPREP_NO_MYCONFIG} = 1;
21

            
added admin tests
Yuki Kimoto authored on 2013-05-16
22
use Gitprep;
23

            
added admin page tests
Yuki Kimoto authored on 2013-05-16
24
note 'Start page';
added admin tests
Yuki Kimoto authored on 2013-05-16
25
{
added _start page tests
Yuki Kimoto authored on 2013-05-16
26
  unlink $db_file;
27

            
28
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
29
  $app->manager->setup_database;
added _start page tests
Yuki Kimoto authored on 2013-05-16
30
  my $t = Test::Mojo->new($app);
31
  $t->ua->max_redirects(3);
add import branch tests
Yuki Kimoto authored on 2013-08-19
32
  
added admin tests
Yuki Kimoto authored on 2013-05-16
33
  # Redirect to _start page
cleanup
Yuki Kimoto authored on 2013-05-24
34
  $t->get_ok('/');
35
  $t->content_like(qr/Create Admin User/);
added admin tests
Yuki Kimoto authored on 2013-05-16
36

            
37
  # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
38
  $t->get_ok('/_start');
39
  $t->content_like(qr/Create Admin User/);
added admin tests
Yuki Kimoto authored on 2013-05-16
40
  
41
  # Password is empty
cleanup
Yuki Kimoto authored on 2013-05-24
42
  $t->post_ok('/_start?op=create', form => {password => ''});
43
  $t->content_like(qr/Password is empty/);
added _start page tests
Yuki Kimoto authored on 2013-05-16
44
  
45
  # Password contains invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
46
  $t->post_ok('/_start?op=create', form => {password => "\t"});
47
  $t->content_like(qr/Password contains invalid character/);
added _start page tests
Yuki Kimoto authored on 2013-05-16
48

            
49
  # Two password don't match
cleanup
Yuki Kimoto authored on 2013-05-24
50
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'b'});
51
  $t->content_like(qr/Two password/);
added _start page tests
Yuki Kimoto authored on 2013-05-16
52
  
53
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
54
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
55
  $t->content_like(qr/Login page/);
added _start page tests
Yuki Kimoto authored on 2013-05-16
56

            
Can't access _start page aft...
Yuki Kimoto authored on 2013-07-20
57
  # Admin user already exists(Redirect to top page)
cleanup
Yuki Kimoto authored on 2013-05-24
58
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
Can't access _start page aft...
Yuki Kimoto authored on 2013-07-20
59
  $t->content_like(qr/Users/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
60
}
61

            
add reset password test
Yuki Kimoto authored on 2013-05-18
62
note 'Admin pages';
added admin page tests
Yuki Kimoto authored on 2013-05-16
63
{
64
  unlink $db_file;
65

            
66
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
67
  $app->manager->setup_database;
added admin page tests
Yuki Kimoto authored on 2013-05-16
68
  my $t = Test::Mojo->new($app);
69
  $t->ua->max_redirects(3);
70

            
71
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
72
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
73
  $t->content_like(qr/Login page/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
74
  
75
  # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
76
  $t->get_ok('/_login');
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
77
  $t->content_like(qr/Login page/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
78
  
79
  # Login fail
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-16
82

            
83
  # Login success
cleanup
Yuki Kimoto authored on 2013-05-24
84
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
85
  $t->content_like(qr/Admin/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
86
  
87
  note 'Admin page';
88
  {
cleanup
Yuki Kimoto authored on 2013-05-24
89
    $t->post_ok('/_admin');
90
    $t->content_like(qr/Admin/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
91
  }
92
  
93
  note 'Admin User page';
94
  {
cleanup
Yuki Kimoto authored on 2013-05-24
95
    $t->get_ok('/_admin/users');
96
    $t->content_like(qr/Admin Users/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
97
  }
added _start page tests
Yuki Kimoto authored on 2013-05-16
98

            
added admin page tests
Yuki Kimoto authored on 2013-05-16
99
  note 'Create User page';
100
  {
added admin user tests
Yuki Kimoto authored on 2013-05-17
101
    # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
102
    $t->get_ok('/_admin/user/create');
103
    $t->content_like(qr/Create User/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
104
    
105
    # User name is empty
cleanup
Yuki Kimoto authored on 2013-05-24
106
    $t->post_ok('/_admin/user/create?op=create', form => {id => ''});
107
    $t->content_like(qr/User name is empty/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
108

            
109
    # User name contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-17
112

            
113
    # User name is too long
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-17
116

            
117
    # Password is empty
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-17
120

            
121
    # Password contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-17
124

            
125
    # Password contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-17
128
    
129
    # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
132
  }
133
    
134
  note 'Admin Users page';
cleanup
Yuki Kimoto authored on 2013-05-24
135
  $t->get_ok('/_admin/users');
136
  $t->content_like(qr/Admin Users/);
137
  $t->content_like(qr/kimoto/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
138
  
139
  note 'Reset password page';
140
  {
141
    # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
145
    
146
    # Password is empty
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
149

            
150
    # Password contains invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
153
    
154
    # Two password don't match
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
157

            
158
    # Reset password
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
161
  }
162

            
163
  note 'Delete user';
164
  {
165
    # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
170

            
171
    # User not exists
cleanup
Yuki Kimoto authored on 2013-05-24
172
    $t->post_ok('/_admin/users?op=delete', form => {user => 'kimoto-notting'});
173
    $t->content_like(qr/Internal/);
added delete user test
Yuki Kimoto authored on 2013-05-18
174

            
175
    # User not exists
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-16
180
  }
add reset password test
Yuki Kimoto authored on 2013-05-18
181
  
182
  note 'logout';
cleanup
Yuki Kimoto authored on 2013-05-24
183
  $t->get_ok('/_logout');
184
  $t->get_ok('/_admin');
185
  $t->content_like(qr/Users/);
add reset password test
Yuki Kimoto authored on 2013-05-18
186
}
187

            
188
note 'Reset password';
189
{
190
  unlink $db_file;
191

            
192
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
193
  $app->manager->setup_database;
add reset password test
Yuki Kimoto authored on 2013-05-18
194
  my $t = Test::Mojo->new($app);
195
  $t->ua->max_redirects(3);
196

            
197
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
198
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
199
  $t->content_like(qr/Login page/);;
add reset password test
Yuki Kimoto authored on 2013-05-18
200

            
201
  # Not loing user can't access
cleanup
Yuki Kimoto authored on 2013-05-24
202
  $t->get_ok('/reset-password');
203
  $t->content_like(qr/Users/);
add reset password test
Yuki Kimoto authored on 2013-05-18
204

            
205
  # Cnahge password(reset_password conf on)
206
  $app->config->{admin}{reset_password} = 1;
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
211
  $app->config->{admin}{reset_password} = 0;
212

            
213
  # Login success
cleanup
Yuki Kimoto authored on 2013-05-24
214
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'b'});
215
  $t->content_like(qr/Admin/);
add reset password test
Yuki Kimoto authored on 2013-05-18
216
  
217
  # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
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
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
235

            
236
  # Reset password
cleanup
Yuki Kimoto authored on 2013-05-24
237
  $t->get_ok('/reset-password?user=kimoto1');
238
  $t->content_like(qr/Reset Password/);
add reset password test
Yuki Kimoto authored on 2013-05-18
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
Yuki Kimoto authored on 2013-05-16
245
}
add create repository tests
Yuki Kimoto authored on 2013-05-19
246

            
add title
Yuki Kimoto authored on 2013-06-12
247
note 'Profile';
add create repository tests
Yuki Kimoto authored on 2013-05-19
248
{
249
  unlink $db_file;
250
  rmtree $rep_home;
251

            
252
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
253
  $app->manager->setup_database;
add create repository tests
Yuki Kimoto authored on 2013-05-19
254
  my $t = Test::Mojo->new($app);
255
  $t->ua->max_redirects(3);
256

            
257
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
258
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
259
  $t->content_like(qr/Login page/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
260

            
261
  # Login as admin
262
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
263

            
264
  # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-19
269
  
270
  # Login as kimoto1
271
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
272

            
add title
Yuki Kimoto authored on 2013-06-12
273
  # Profile
cleanup
Yuki Kimoto authored on 2013-05-24
274
  $t->get_ok('/kimoto1/_settings');
add title
Yuki Kimoto authored on 2013-06-12
275
  $t->content_like(qr/Profile/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
276
  
277
  # Other user can't access
cleanup
Yuki Kimoto authored on 2013-05-24
278
  $t->get_ok('/kimoto2/_settings');
279
  $t->content_like(qr/Users/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
280
  
281
  note 'Create repository';
282
  {
283
    # Create repository page
cleanup
Yuki Kimoto authored on 2013-05-24
284
    $t->get_ok('/_new');
285
    $t->content_like(qr/Create repository/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
286
    
287
    # Not logined user can't access
288
    $t->get_ok('/_logout');
cleanup
Yuki Kimoto authored on 2013-05-24
289
    $t->get_ok('/_new');
290
    $t->content_like(qr/Users/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
291
    $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
292
    
293
    # Create repository
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-25
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
Yuki Kimoto authored on 2013-05-19
300

            
fix bug that forst . is not ...
Yuki Kimoto authored on 2014-04-21
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
Yuki Kimoto authored on 2013-05-19
307
    # Create repository(with readme)
cleanup
Yuki Kimoto authored on 2013-05-24
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...
Yuki Kimoto authored on 2013-11-16
311
    $t->content_like(qr/README\.md/);
safe first commit with READM...
Yuki Kimoto authored on 2013-06-03
312
    $t->content_like(qr/kimoto1\@localhost/);
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
313
    $t->content_like(qr/Hello/);
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
314

            
simplify rename project
Yuki Kimoto authored on 2013-05-22
315
    # Settings page(don't has README)
cleanup
Yuki Kimoto authored on 2013-05-24
316
    $t->get_ok('/kimoto1/t1/settings');
317
    $t->content_like(qr/Settings/);
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
318

            
simplify rename project
Yuki Kimoto authored on 2013-05-22
319
    # Settings page(has README)
cleanup
Yuki Kimoto authored on 2013-05-24
320
    $t->get_ok('/kimoto1/t2/settings');
321
    $t->content_like(qr/Settings/);
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
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
Yuki Kimoto authored on 2013-05-19
327
  }
cleanup
Yuki Kimoto authored on 2013-05-24
328
  
329
  note 'Project settings';
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-25
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...
Yuki Kimoto authored on 2013-05-25
350
      # Change description(t1)
add change description test
Yuki Kimoto authored on 2013-05-25
351
      $t->post_ok("/kimoto1/t1/settings?op=change-description", form => {description => 'あああ'});
352
      $t->content_like(qr/Description is saved/);
add default branch test
Yuki Kimoto authored on 2013-05-25
353
      $t->content_like(qr/あああ/);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
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
Yuki Kimoto authored on 2013-05-25
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
Yuki Kimoto authored on 2016-03-31
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...
Yuki Kimoto authored on 2013-05-24
379
    }
add delete project test
Yuki Kimoto authored on 2013-05-25
380
    
381
    note 'Delete project';
382
    {
add fork test
Yuki Kimoto authored on 2013-05-25
383
      $t->post_ok('/kimoto1/t1/settings?op=delete-project');
384
      $t->content_like(qr/Repository t1 is deleted/);
add delete project test
Yuki Kimoto authored on 2013-05-25
385
      $t->get_ok('/kimoto1');
add fork test
Yuki Kimoto authored on 2013-05-25
386
      $t->content_unlike(qr/t1/);
add delete project test
Yuki Kimoto authored on 2013-05-25
387
    }
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
388
  }
add create repository tests
Yuki Kimoto authored on 2013-05-19
389
}
add fork test
Yuki Kimoto authored on 2013-05-25
390

            
391
note 'fork';
392
{
393
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
394
  $app->manager->setup_database;
add fork test
Yuki Kimoto authored on 2013-05-25
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...
Yuki Kimoto authored on 2013-05-25
408
  $t->content_like(qr/いいい/);
add fork test
Yuki Kimoto authored on 2013-05-25
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...
Yuki Kimoto authored on 2013-05-29
416

            
add network test
Yuki Kimoto authored on 2013-05-29
417
note 'Network';
418
{
419
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
420
  $app->manager->setup_database;
add network test
Yuki Kimoto authored on 2013-05-29
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...
Yuki Kimoto authored on 2013-05-29
437
note 'Delete branch';
438
{
439
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
440
  $app->manager->setup_database;
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
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
Yuki Kimoto authored on 2013-05-29
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...
Yuki Kimoto authored on 2013-05-29
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
Yuki Kimoto authored on 2016-01-27
459
  $t->content_like(qr/Delete/);
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
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...
Yuki Kimoto authored on 2013-08-19
468

            
469
note 'import-branch';
470
{
471
  my $app = Gitprep->new;
separete database creating l...
Yuki Kimoto authored on 2016-04-06
472
  $app->manager->setup_database;
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
473
  my $t = Test::Mojo->new($app);
474
  $t->ua->max_redirects(3);
475

            
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
479

            
480
  # Create project
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
483
  
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
511
  
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
534
}
add private repository and c...
Yuki Kimoto authored on 2013-11-18
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...
Yuki Kimoto authored on 2016-04-06
542
  $app->manager->setup_database;
add private repository and c...
Yuki Kimoto authored on 2013-11-18
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
Yuki Kimoto authored on 2016-03-31
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...
Yuki Kimoto authored on 2013-11-18
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
}