gitprep / xt / user.t /
Newer Older
601 lines | 19.258kb
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;
29
  my $t = Test::Mojo->new($app);
30
  $t->ua->max_redirects(3);
add import branch tests
Yuki Kimoto authored on 2013-08-19
31
  
added admin tests
Yuki Kimoto authored on 2013-05-16
32
  # Redirect to _start page
cleanup
Yuki Kimoto authored on 2013-05-24
33
  $t->get_ok('/');
34
  $t->content_like(qr/Create Admin User/);
added admin tests
Yuki Kimoto authored on 2013-05-16
35

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

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

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

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

            
65
  my $app = Gitprep->new;
66
  my $t = Test::Mojo->new($app);
67
  $t->ua->max_redirects(3);
68

            
69
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
70
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
71
  $t->content_like(qr/Login page/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
72
  
73
  # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
74
  $t->get_ok('/_login');
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
75
  $t->content_like(qr/Login page/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
76
  
77
  # Login fail
cleanup
Yuki Kimoto authored on 2013-05-24
78
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'b'});
79
  $t->content_like(qr/User name or password is wrong/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
80

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

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

            
107
    # User name contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
108
    $t->post_ok('/_admin/user/create?op=create', form => {id => '&'});
109
    $t->content_like(qr/User name contain invalid character/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
110

            
111
    # User name is too long
cleanup
Yuki Kimoto authored on 2013-05-24
112
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'a' x 21});
113
    $t->content_like(qr/User name is too long/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
114

            
115
    # Password is empty
cleanup
Yuki Kimoto authored on 2013-05-24
116
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'a', password => ''});
117
    $t->content_like(qr/Password is empty/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
118

            
119
    # Password contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
120
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'a', password => "\t"});
121
    $t->content_like(qr/Password contain invalid character/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
122

            
123
    # Password contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
124
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'a', password => 'a', password2 => 'b'});
125
    $t->content_like(qr/Two password/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
126
    
127
    # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
128
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
129
    $t->content_like(qr/Success.*created/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
130
  }
131
    
132
  note 'Admin Users page';
cleanup
Yuki Kimoto authored on 2013-05-24
133
  $t->get_ok('/_admin/users');
134
  $t->content_like(qr/Admin Users/);
135
  $t->content_like(qr/kimoto/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
136
  
137
  note 'Reset password page';
138
  {
139
    # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
140
    $t->get_ok('/reset-password?user=kimoto');
141
    $t->content_like(qr/Reset Password/);
142
    $t->content_like(qr/kimoto/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
143
    
144
    # Password is empty
cleanup
Yuki Kimoto authored on 2013-05-24
145
    $t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => ''});
146
    $t->content_like(qr/Password is empty/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
147

            
148
    # Password contains invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
149
    $t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => "\t"});
150
    $t->content_like(qr/Password contains invalid character/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
151
    
152
    # Two password don't match
cleanup
Yuki Kimoto authored on 2013-05-24
153
    $t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => 'a', password2 => 'b'});
154
    $t->content_like(qr/Two password/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
155

            
156
    # Reset password
cleanup
Yuki Kimoto authored on 2013-05-24
157
    $t->post_ok('/reset-password?user=kimoto&op=reset', form => {password => 'a', password2 => 'a'});
158
    $t->content_like(qr/Success.*changed/);
added delete user test
Yuki Kimoto authored on 2013-05-18
159
  }
160

            
161
  note 'Delete user';
162
  {
163
    # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
164
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto-tmp', password => 'a', password2 => 'a'});
165
    $t->content_like(qr/kimoto-tmp/);
166
    $t->get_ok('/_admin/users');
167
    $t->content_like(qr/kimoto-tmp/);
added delete user test
Yuki Kimoto authored on 2013-05-18
168

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

            
173
    # User not exists
cleanup
Yuki Kimoto authored on 2013-05-24
174
    $t->post_ok('/_admin/users?op=delete', form => {user => 'kimoto-tmp'});
175
    $t->content_like(qr/User.*deleted/);
176
    $t->get_ok('/_admin/users');
177
    $t->content_unlike(qr/kimoto-tmp/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
178
  }
add reset password test
Yuki Kimoto authored on 2013-05-18
179
  
180
  note 'logout';
cleanup
Yuki Kimoto authored on 2013-05-24
181
  $t->get_ok('/_logout');
182
  $t->get_ok('/_admin');
183
  $t->content_like(qr/Users/);
add reset password test
Yuki Kimoto authored on 2013-05-18
184
}
185

            
186
note 'Reset password';
187
{
188
  unlink $db_file;
189

            
190
  my $app = Gitprep->new;
191
  my $t = Test::Mojo->new($app);
192
  $t->ua->max_redirects(3);
193

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

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

            
202
  # Cnahge password(reset_password conf on)
203
  $app->config->{admin}{reset_password} = 1;
cleanup
Yuki Kimoto authored on 2013-05-24
204
  $t->get_ok('/reset-password');
205
  $t->content_like(qr/Reset Password/);
206
  $t->post_ok('/reset-password?op=reset', form => {password => 'b', password2 => 'b'});
207
  $t->content_like(qr/Success.*changed/);
add reset password test
Yuki Kimoto authored on 2013-05-18
208
  $app->config->{admin}{reset_password} = 0;
209

            
210
  # Login success
cleanup
Yuki Kimoto authored on 2013-05-24
211
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'b'});
212
  $t->content_like(qr/Admin/);
add reset password test
Yuki Kimoto authored on 2013-05-18
213
  
214
  # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
215
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', password => 'a', password2 => 'a'});
216
  $t->content_like(qr/kimoto1/);
217
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
218
  $t->content_like(qr/kimoto2/);
add reset password test
Yuki Kimoto authored on 2013-05-18
219
  
220
  # Logout
221
  $t->get_ok('/_logout');
222
  
223
  # Login as kimoto
224
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
225
  $t->get_ok('/')->content_like(qr/kimoto1/);
226

            
227
  # Don't change other user password
cleanup
Yuki Kimoto authored on 2013-05-24
228
  $t->get_ok('/reset-password?user=kimoto2');
229
  $t->content_like(qr/Users/);
230
  $t->post_ok('/reset-password?user=kimoto2&op=reset', form => {password => 'b', password2 => 'b'});
231
  $t->content_like(qr/Users/);
add reset password test
Yuki Kimoto authored on 2013-05-18
232

            
233
  # Reset password
cleanup
Yuki Kimoto authored on 2013-05-24
234
  $t->get_ok('/reset-password?user=kimoto1');
235
  $t->content_like(qr/Reset Password/);
add reset password test
Yuki Kimoto authored on 2013-05-18
236
  $t->post_ok('/reset-password?user=kimoto1&op=reset', form => {password => 'b', password2 => 'b'});
237
  
238
  # Login as kimoto
239
  $t->get_ok('/_logout');
240
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'b'});
241
  $t->get_ok('/')->content_like(qr/kimoto1/);
added admin tests
Yuki Kimoto authored on 2013-05-16
242
}
add create repository tests
Yuki Kimoto authored on 2013-05-19
243

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

            
249
  my $app = Gitprep->new;
250
  my $t = Test::Mojo->new($app);
251
  $t->ua->max_redirects(3);
252

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

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

            
260
  # Create user
cleanup
Yuki Kimoto authored on 2013-05-24
261
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', password => 'a', password2 => 'a'});
262
  $t->content_like(qr/kimoto1/);
263
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
264
  $t->content_like(qr/kimoto2/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
265
  
266
  # Login as kimoto1
267
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
268

            
add title
Yuki Kimoto authored on 2013-06-12
269
  # Profile
cleanup
Yuki Kimoto authored on 2013-05-24
270
  $t->get_ok('/kimoto1/_settings');
add title
Yuki Kimoto authored on 2013-06-12
271
  $t->content_like(qr/Profile/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
272
  
273
  # Other user can't access
cleanup
Yuki Kimoto authored on 2013-05-24
274
  $t->get_ok('/kimoto2/_settings');
275
  $t->content_like(qr/Users/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
276
  
277
  note 'Create repository';
278
  {
279
    # Create repository page
cleanup
Yuki Kimoto authored on 2013-05-24
280
    $t->get_ok('/_new');
281
    $t->content_like(qr/Create repository/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
282
    
283
    # Not logined user can't access
284
    $t->get_ok('/_logout');
cleanup
Yuki Kimoto authored on 2013-05-24
285
    $t->get_ok('/_new');
286
    $t->content_like(qr/Users/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
287
    $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
288
    
289
    # Create repository
cleanup
Yuki Kimoto authored on 2013-05-24
290
    $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello'});
291
    $t->content_like(qr/Create a new repository on the command line/);
292
    $t->content_like(qr/t1\.git/);
293
    $t->content_like(qr/Hello/);
add git export file test
Yuki Kimoto authored on 2013-05-25
294
    ok(-f "$rep_home/kimoto1/t1.git/git-daemon-export-ok");
295
    ok(-f "$rep_home/kimoto1/t1.git/hooks/post-update");
add create repository tests
Yuki Kimoto authored on 2013-05-19
296

            
fix bug that forst . is not ...
Yuki Kimoto authored on 2014-04-21
297
    # Create repository(first character is .)
298
    $t->post_ok('/_new?op=create', form => {project => '.dot', description => 'Dot'});
299
    $t->content_like(qr/Create a new repository on the command line/);
300
    $t->content_like(qr/\.dot\.git/);
301
    $t->content_like(qr/Dot/);
302

            
add create repository tests
Yuki Kimoto authored on 2013-05-19
303
    # Create repository(with readme)
cleanup
Yuki Kimoto authored on 2013-05-24
304
    $t->post_ok('/_new?op=create', form => {project => 't2', description => 'Hello', readme => 1});
305
    $t->content_like(qr/first commit/);
306
    $t->content_like(qr/t2\.git/);
default readme file is chang...
Yuki Kimoto authored on 2013-11-16
307
    $t->content_like(qr/README\.md/);
safe first commit with READM...
Yuki Kimoto authored on 2013-06-03
308
    $t->content_like(qr/kimoto1\@localhost/);
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
309
    $t->content_like(qr/Hello/);
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
310

            
simplify rename project
Yuki Kimoto authored on 2013-05-22
311
    # Settings page(don't has README)
cleanup
Yuki Kimoto authored on 2013-05-24
312
    $t->get_ok('/kimoto1/t1/settings');
313
    $t->content_like(qr/Settings/);
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(has README)
cleanup
Yuki Kimoto authored on 2013-05-24
316
    $t->get_ok('/kimoto1/t2/settings');
317
    $t->content_like(qr/Settings/);
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
318

            
319
    # Create repository(with private)
320
    $t->post_ok('/_new?op=create', form => {project => 't_private', private => 1});
321
    $t->content_like(qr/t_private\.git/);
322
    $t->content_like(qr/icon-lock/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
323
  }
cleanup
Yuki Kimoto authored on 2013-05-24
324
  
325
  note 'Project settings';
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
326
  {
327
    note 'Rename project';
328
    {
329
      # Empty
330
      $t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {});
331
      $t->content_like(qr/Repository name is empty/);
332
      
333
      # Invalid character
334
      $t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {'to-project' => '&'});
335
      $t->content_like(qr/Repository name contains invalid charactor/);
336
      
337
      # Rename project
338
      $t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {'to-project' => 't3'});
339
      $t->content_like(qr/Repository name is renamed to t3/);
add change description test
Yuki Kimoto authored on 2013-05-25
340
      $t->post_ok('/kimoto1/t3/settings?op=rename-project', form => {'to-project' => 't2'});
341
      $t->content_like(qr/Repository name is renamed to t2/);
342
    }
343
    
344
    note 'Change description';
345
    {
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
346
      # Change description(t1)
add change description test
Yuki Kimoto authored on 2013-05-25
347
      $t->post_ok("/kimoto1/t1/settings?op=change-description", form => {description => 'あああ'});
348
      $t->content_like(qr/Description is saved/);
add default branch test
Yuki Kimoto authored on 2013-05-25
349
      $t->content_like(qr/あああ/);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
350

            
351
      # Change description(t2)
352
      $t->post_ok("/kimoto1/t2/settings?op=change-description", form => {description => 'いいい'});
353
      $t->content_like(qr/Description is saved/);
354
      $t->content_like(qr/いいい/);
add default branch test
Yuki Kimoto authored on 2013-05-25
355
    }
356
    
357
    note 'Change default branch';
358
    {
359
      # Default branch default
360
      $t->get_ok('/kimoto1/t1/settings');
361
      $t->content_like(qr/master/);
362
      
363
      # Change default branch
364
      my $cmd = "git --git-dir=$rep_home/kimoto1/t2.git branch b1";
365
      system($cmd) == 0 or die "Can't execute git branch";
366
      $t->get_ok('/kimoto1/t2/settings');
367
      $t->content_like(qr/b1/);
368
      $t->post_ok("/kimoto1/t2/settings?op=default-branch", form => {'default-branch' => 'b1'});
369
      $t->content_like(qr/Default branch is changed to b1/);
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
370
    }
add delete project test
Yuki Kimoto authored on 2013-05-25
371
    
372
    note 'Delete project';
373
    {
add fork test
Yuki Kimoto authored on 2013-05-25
374
      $t->post_ok('/kimoto1/t1/settings?op=delete-project');
375
      $t->content_like(qr/Repository t1 is deleted/);
add delete project test
Yuki Kimoto authored on 2013-05-25
376
      $t->get_ok('/kimoto1');
add fork test
Yuki Kimoto authored on 2013-05-25
377
      $t->content_unlike(qr/t1/);
add delete project test
Yuki Kimoto authored on 2013-05-25
378
    }
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
379
  }
add create repository tests
Yuki Kimoto authored on 2013-05-19
380
}
add fork test
Yuki Kimoto authored on 2013-05-25
381

            
382
note 'fork';
383
{
384
  my $app = Gitprep->new;
385
  my $t = Test::Mojo->new($app);
386
  $t->ua->max_redirects(3);
387
  
388
  # Don't logind
389
  $t->get_ok("/kimoto1/t2/fork");
390
  $t->content_like(qr/Users/);
391

            
392
  # Login as kimoto2
393
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
394
  
395
  # Fork kimoto1/t2
396
  $t->get_ok("/kimoto1/t2/fork");
397
  $t->content_like(qr#Repository is forked from /kimoto1/t2#);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
398
  $t->content_like(qr/いいい/);
add fork test
Yuki Kimoto authored on 2013-05-25
399
  
400
  # Fork kimoto1/t2 again
401
  $t->get_ok("/kimoto1/t2/fork");
402
  $t->content_like(qr/forked from/);
403
  $t->content_like(qr#kimoto1/t2#);
404
  $t->content_unlike(qr/Repository is forked from/);
405
}
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
406

            
add network test
Yuki Kimoto authored on 2013-05-29
407
note 'Network';
408
{
409
  my $app = Gitprep->new;
410
  my $t = Test::Mojo->new($app);
411
  $t->ua->max_redirects(3);
412

            
413
  $t->get_ok("/kimoto1/t2/network");
414
  $t->content_like(qr/Members of the t2/);
415
  $t->content_like(qr/My branch.*kimoto1.*t2.*master/s);
416
  $t->content_like(qr/Member branch.*kimoto2.*t2.*master/s);
417
  
418
  note 'Graph';
419
  {
420
    $t->get_ok("/kimoto1/t2/network/graph/master...kimoto2/t2/master");
421
    $t->content_like(qr/Graph/);
422
    $t->content_like(qr/first commit/);
423
  }
424
}
425

            
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
426
note 'Delete branch';
427
{
428
  my $app = Gitprep->new;
429
  my $t = Test::Mojo->new($app);
430
  $t->ua->max_redirects(3);
431
  
432
  # No delete branch button
433
  $t->get_ok("/kimoto1/t2/branches");
434
  $t->content_like(qr/Branches/);
435
  $t->content_unlike(qr/Delete branch/);
add test
Yuki Kimoto authored on 2013-05-29
436
  
437
  # Can't delete branch when no login
438
  $t->post_ok('/kimoto1/t2/branches?op=delete', form => {branch => 'tmp_branch'})
439
    ->content_like(qr/Users/);
440
  
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
441

            
442
  # Login as kimoto1
443
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
444
  my $cmd = "git --git-dir=$rep_home/kimoto1/t2.git branch tmp_branch";
445
  system($cmd) == 0 or die "Can't execute git branch";
446
  $t->get_ok("/kimoto1/t2/branches");
improve branch design
Yuki Kimoto authored on 2016-01-27
447
  $t->content_like(qr/Delete/);
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
448
  $t->content_like(qr/tmp_branch/);
449
  
450
  # Delete branch
451
  $t->post_ok('/kimoto1/t2/branches?op=delete', form => {branch => 'tmp_branch'});
452
  $t->content_like(qr/Branch tmp_branch is deleted/);
453
  $t->get_ok('/kimoto1/t2/branches');
454
  $t->content_unlike(qr/tmp_branch/);
455
}
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
456

            
457
note 'import-branch';
458
{
459
  my $app = Gitprep->new;
460
  my $t = Test::Mojo->new($app);
461
  $t->ua->max_redirects(3);
462

            
add import branch tests
Yuki Kimoto authored on 2013-08-19
463
  # Login as kimoto1
464
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
465
  $t->get_ok('/')->content_like(qr/Logined as kimoto1 /);
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
466

            
467
  # Create project
add import branch tests
Yuki Kimoto authored on 2013-08-19
468
  $t->post_ok('/_new?op=create', form => {project => 'import-branch1', description => '', readme => 1});
469
  $t->get_ok('/kimoto1')->content_like(qr/import-branch1/);
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
470
  
add import branch tests
Yuki Kimoto authored on 2013-08-19
471
  # Login as kimoto2
472
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
473
  $t->get_ok('/')->content_like(qr/Logined as kimoto2 /);
474

            
475
  # Fork kimoto1/import-branch1
476
  $t->get_ok("/kimoto1/import-branch1/fork");
477
  $t->content_like(qr#Repository is forked from /kimoto1/import-branch1#);
478

            
479
  # Access not valid user
480
  $t->get_ok('/kimoto1/import-branch1/network');
481
  $t->content_like(qr/Network/);
482
  $t->content_unlike(qr/Import/);
483
  $t->get_ok('/kimoto1/import-branch1/import-branch/kimoto2/import-branch1?remote-branch=master');
484
  $t->content_like(qr/ Index page /);
485
  
486
  # Show network page import button
487
  $t->get_ok('/kimoto2/import-branch1/network');
488
  $t->content_like(qr/Network/);
489
  $t->content_like(qr/Import/);
490
  
491
  # Import branch page access
492
  $t->get_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?remote-branch=master');
493
  $t->content_like(qr/Import branch/);
494

            
495
  # Invalid parameters
496
  $t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?remote-branch=master&op=import');
497
  $t->content_like(qr/Branch name is empty/);
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
498
  
add import branch tests
Yuki Kimoto authored on 2013-08-19
499
  # Import branch
500
  $t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?op=import', form => {
501
    branch => 'new1',
502
    'remote-branch' => 'master'
503
  });
504
  $t->content_like(qr#Success: import#);
505
  $t->get_ok('/kimoto2/import-branch1/branches')->content_like(qr/new1/);
506

            
507
  # Import same name branch fail
508
  $t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?op=import', form => {
509
    branch => 'new1',
510
    'remote-branch' => 'master'
511
  });
512
  $t->content_like(qr#already exists#);
513

            
514
  # Import force
515
  $t->post_ok('/kimoto2/import-branch1/import-branch/kimoto1/import-branch1?op=import', form => {
516
    branch => 'new1',
517
    'remote-branch' => 'master',
518
    force => 1
519
  });
520
  $t->content_like(qr#Success: force import#);
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
521
}
add private repository and c...
Yuki Kimoto authored on 2013-11-18
522

            
523
note 'Private repository and collaborator';
524
{
525
  unlink $db_file;
526
  rmtree $rep_home;
527

            
528
  my $app = Gitprep->new;
529
  my $t = Test::Mojo->new($app);
530
  $t->ua->max_redirects(3);
531

            
532
  # Create admin user
533
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
534
  $t->content_like(qr/Login page/);
535

            
536
  # Login success
537
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
538
  $t->content_like(qr/Admin/);
539
  
540
  # Create user
541
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
542
  $t->content_like(qr/Success.*created/);
543
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
544
  $t->content_like(qr/Success.*created/);
545

            
546
  # Login as kimoto
547
  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
548
  $t->get_ok('/')->content_like(qr/kimoto/);
549

            
550
  # Create repository
551
  $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1});
552
  $t->content_like(qr/README/);
553
  
554
  # Check private repository
555
  $t->post_ok("/kimoto/t1/settings?op=private", form => {private => 1});
556
  $t->content_like(qr/Repository is private/);
557
  
558
  # Can access repository myself
559
  $t->get_ok("/kimoto/t1");
560
  $t->content_like(qr/README/);
561

            
562
  # Login as kimoto2
563
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
564
  $t->get_ok('/')->content_like(qr/kimoto2/);
565
  
566
  # Can't access private repository
567
  $t->get_ok("/kimoto/t1");
568
  $t->content_like(qr/t1 is private repository/);
569
  
570
  # Login as kimoto
571
  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
572
  $t->get_ok('/')->content_like(qr/kimoto/);
573
  
574
  # Add collaborator
575
  $t->post_ok("/kimoto/t1/settings/collaboration?op=add", form => {collaborator => 'kimoto2'});
576
  $t->content_like(qr/Collaborator kimoto2 is added/);
577
  
578
  # Login as kimoto2
579
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
580
  $t->get_ok('/')->content_like(qr/kimoto2/);
581
  
582
  # Can access private repository from collaborator
583
  $t->get_ok("/kimoto/t1");
584
  $t->content_like(qr/README/);
585

            
586
  # Login as kimoto
587
  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
588
  $t->get_ok('/')->content_like(qr/kimoto/);
589

            
590
  # Delete collaborator
591
  $t->post_ok("/kimoto/t1/settings/collaboration?op=remove", form => {collaborator => 'kimoto2'});
592
  $t->content_like(qr/Collaborator kimoto2 is removed/);
593

            
594
  # Login as kimoto2
595
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
596
  $t->get_ok('/')->content_like(qr/kimoto2/);
597

            
598
  # Can't access private repository
599
  $t->get_ok("/kimoto/t1");
600
  $t->content_like(qr/t1 is private repository/);
601
}