gitprep / xt / user.t /
Newer Older
657 lines | 22.021kb
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/;
fix some tests
Yuki Kimoto authored on 2016-04-21
11
use Mojo::Server;
added admin tests
Yuki Kimoto authored on 2013-05-16
12

            
13
use Test::Mojo;
14

            
cleanup tests
Yuki Kimoto authored on 2016-04-14
15
# Data directory
fix tests
Yuki Kimoto authored on 2016-04-14
16
my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/user";
cleanup tests
Yuki Kimoto authored on 2016-04-14
17

            
added admin tests
Yuki Kimoto authored on 2013-05-16
18
# Test DB
cleanup tests
Yuki Kimoto authored on 2016-04-16
19
my $db_file = "$data_dir/gitprep.db";
added admin tests
Yuki Kimoto authored on 2013-05-16
20

            
21
# Test Repository home
cleanup tests
Yuki Kimoto authored on 2016-04-16
22
my $rep_home = "$data_dir/rep";
added admin tests
Yuki Kimoto authored on 2013-05-16
23

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

            
added admin tests
Yuki Kimoto authored on 2013-05-16
26
use Gitprep;
27

            
added admin page tests
Yuki Kimoto authored on 2013-05-16
28
note 'Start page';
added admin tests
Yuki Kimoto authored on 2013-05-16
29
{
added _start page tests
Yuki Kimoto authored on 2013-05-16
30
  unlink $db_file;
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
35
  
added _start page tests
Yuki Kimoto authored on 2013-05-16
36
  my $t = Test::Mojo->new($app);
37
  $t->ua->max_redirects(3);
add import branch tests
Yuki Kimoto authored on 2013-08-19
38
  
added admin tests
Yuki Kimoto authored on 2013-05-16
39
  # Redirect to _start page
cleanup
Yuki Kimoto authored on 2013-05-24
40
  $t->get_ok('/');
41
  $t->content_like(qr/Create Admin User/);
added admin tests
Yuki Kimoto authored on 2013-05-16
42

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

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

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

            
add user update test
Yuki Kimoto authored on 2016-04-08
68
note 'Admin page';
added admin page tests
Yuki Kimoto authored on 2013-05-16
69
{
70
  unlink $db_file;
71

            
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
75

            
added admin page tests
Yuki Kimoto authored on 2013-05-16
76
  my $t = Test::Mojo->new($app);
77
  $t->ua->max_redirects(3);
78

            
79
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
80
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
81
  $t->content_like(qr/Login page/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
82
  
83
  # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
84
  $t->get_ok('/_login');
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
85
  $t->content_like(qr/Login page/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
86
  
87
  # Login fail
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-16
90

            
91
  # Login success
cleanup
Yuki Kimoto authored on 2013-05-24
92
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
93
  $t->content_like(qr/Admin/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
94
  
add user update test
Yuki Kimoto authored on 2016-04-08
95
  note 'Admin page - top';
added admin page tests
Yuki Kimoto authored on 2013-05-16
96
  {
cleanup
Yuki Kimoto authored on 2013-05-24
97
    $t->post_ok('/_admin');
98
    $t->content_like(qr/Admin/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
99
  }
100
  
add user update test
Yuki Kimoto authored on 2016-04-08
101
  note 'Admin page -  User page';
added admin page tests
Yuki Kimoto authored on 2013-05-16
102
  {
cleanup
Yuki Kimoto authored on 2013-05-24
103
    $t->get_ok('/_admin/users');
104
    $t->content_like(qr/Admin Users/);
added admin page tests
Yuki Kimoto authored on 2013-05-16
105
  }
added _start page tests
Yuki Kimoto authored on 2013-05-16
106

            
add user update test
Yuki Kimoto authored on 2016-04-08
107
  note 'Admin page - Create User';
added admin page tests
Yuki Kimoto authored on 2013-05-16
108
  {
added admin user tests
Yuki Kimoto authored on 2013-05-17
109
    # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
110
    $t->get_ok('/_admin/user/create');
111
    $t->content_like(qr/Create User/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
112
    
113
    # User name is empty
cleanup
Yuki Kimoto authored on 2013-05-24
114
    $t->post_ok('/_admin/user/create?op=create', form => {id => ''});
add user update page
Yuki Kimoto authored on 2016-04-07
115
    $t->content_like(qr/User id is empty/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
116

            
117
    # User name contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
118
    $t->post_ok('/_admin/user/create?op=create', form => {id => '&'});
add user update page
Yuki Kimoto authored on 2016-04-07
119
    $t->content_like(qr/User id contain invalid character/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
120

            
121
    # User name is too long
cleanup
Yuki Kimoto authored on 2013-05-24
122
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'a' x 21});
add user update page
Yuki Kimoto authored on 2016-04-07
123
    $t->content_like(qr/User id is too long/);
added admin user tests
Yuki Kimoto authored on 2013-05-17
124

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

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

            
133
    # Password contain invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-17
136
    
137
    # Create user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
138
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', name => 'Kimoto', email => 'kimoto@gitprep.example', password => 'a', password2 => 'a'});
cleanup
Yuki Kimoto authored on 2013-05-24
139
    $t->content_like(qr/Success.*created/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
140
  }
141
    
add user update test
Yuki Kimoto authored on 2016-04-08
142
  note 'Admin page - Users page';
cleanup
Yuki Kimoto authored on 2013-05-24
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...
Yuki Kimoto authored on 2016-04-07
146
  $t->content_like(qr/Kimoto/);
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
147
  $t->content_like(qr/kimoto\@gitprep\.example/);
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
148
  
add user update test
Yuki Kimoto authored on 2016-04-08
149
  note 'Admin page - Reset password';
added tests and move delete ...
Yuki Kimoto authored on 2013-05-18
150
  {
151
    # Page access
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
155
    
156
    # Password is empty
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
159

            
160
    # Password contains invalid character
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
163
    
164
    # Two password don't match
cleanup
Yuki Kimoto authored on 2013-05-24
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 ...
Yuki Kimoto authored on 2013-05-18
167

            
168
    # Reset password
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
171
  }
172

            
add user update test
Yuki Kimoto authored on 2016-04-08
173
  note 'Admin page - Update user';
174
  {
175
    # Create user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-08
177
    $t->content_like(qr/kimoto-update/);
178
    
179
    # Update user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-08
181
    $t->content_like(qr/Kimoto-Update2/);
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
182
    $t->content_like(qr/kimoto-update2\@gitprep\.example/);
add user update test
Yuki Kimoto authored on 2016-04-08
183
  }
184

            
185
  note 'Admin page - Delete user';
added delete user test
Yuki Kimoto authored on 2013-05-18
186
  {
187
    # Create user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
188
    $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto-tmp', email => 'kimoto-tmp@gitprep.example', password => 'a', password2 => 'a'});
cleanup
Yuki Kimoto authored on 2013-05-24
189
    $t->content_like(qr/kimoto-tmp/);
190
    $t->get_ok('/_admin/users');
191
    $t->content_like(qr/kimoto-tmp/);
added delete user test
Yuki Kimoto authored on 2013-05-18
192

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

            
197
    # User not exists
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-16
202
  }
add reset password test
Yuki Kimoto authored on 2013-05-18
203
  
204
  note 'logout';
cleanup
Yuki Kimoto authored on 2013-05-24
205
  $t->get_ok('/_logout');
206
  $t->get_ok('/_admin');
207
  $t->content_like(qr/Users/);
add reset password test
Yuki Kimoto authored on 2013-05-18
208
}
209

            
210
note 'Reset password';
211
{
212
  unlink $db_file;
213

            
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
217

            
add reset password test
Yuki Kimoto authored on 2013-05-18
218
  my $t = Test::Mojo->new($app);
219
  $t->ua->max_redirects(3);
220

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

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

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

            
237
  # Login success
cleanup
Yuki Kimoto authored on 2013-05-24
238
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'b'});
239
  $t->content_like(qr/Admin/);
add reset password test
Yuki Kimoto authored on 2013-05-18
240
  
241
  # Create user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
242
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', email => 'kimoto1@gitprep.example', password => 'a', password2 => 'a'});
cleanup
Yuki Kimoto authored on 2013-05-24
243
  $t->content_like(qr/kimoto1/);
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
244
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', email => 'kimoto2@gitprep.example', password => 'a', password2 => 'a'});
cleanup
Yuki Kimoto authored on 2013-05-24
245
  $t->content_like(qr/kimoto2/);
add reset password test
Yuki Kimoto authored on 2013-05-18
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
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-18
259

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

            
add title
Yuki Kimoto authored on 2013-06-12
271
note 'Profile';
add create repository tests
Yuki Kimoto authored on 2013-05-19
272
{
273
  unlink $db_file;
274
  rmtree $rep_home;
275

            
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
279

            
add create repository tests
Yuki Kimoto authored on 2013-05-19
280
  my $t = Test::Mojo->new($app);
281
  $t->ua->max_redirects(3);
282

            
283
  # Create admin user
cleanup
Yuki Kimoto authored on 2013-05-24
284
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
285
  $t->content_like(qr/Login page/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
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...
Yuki Kimoto authored on 2016-04-21
291
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', email => 'kimoto1@gitprep.example', password => 'a', password2 => 'a'});
cleanup
Yuki Kimoto authored on 2013-05-24
292
  $t->content_like(qr/kimoto1/);
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
293
  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', email => 'kimoto2@gitprep.example', password => 'a', password2 => 'a'});
cleanup
Yuki Kimoto authored on 2013-05-24
294
  $t->content_like(qr/kimoto2/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
295
  
296
  # Login as kimoto1
297
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
298

            
add title
Yuki Kimoto authored on 2013-06-12
299
  # Profile
cleanup
Yuki Kimoto authored on 2013-05-24
300
  $t->get_ok('/kimoto1/_settings');
add title
Yuki Kimoto authored on 2013-06-12
301
  $t->content_like(qr/Profile/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
302
  
303
  # Other user can't access
cleanup
Yuki Kimoto authored on 2013-05-24
304
  $t->get_ok('/kimoto2/_settings');
305
  $t->content_like(qr/Users/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
306
  
307
  note 'Create repository';
308
  {
309
    # Create repository page
cleanup
Yuki Kimoto authored on 2013-05-24
310
    $t->get_ok('/_new');
311
    $t->content_like(qr/Create repository/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
312
    
313
    # Not logined user can't access
314
    $t->get_ok('/_logout');
cleanup
Yuki Kimoto authored on 2013-05-24
315
    $t->get_ok('/_new');
316
    $t->content_like(qr/Users/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
317
    $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
318
    
319
    # Create repository
fix some tests
Yuki Kimoto authored on 2016-04-21
320
    $main::x = 1;
cleanup
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-25
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
Yuki Kimoto authored on 2013-05-19
327

            
fix bug that forst . is not ...
Yuki Kimoto authored on 2014-04-21
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
Yuki Kimoto authored on 2013-05-19
334
    # Create repository(with readme)
cleanup
Yuki Kimoto authored on 2013-05-24
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...
Yuki Kimoto authored on 2013-11-16
338
    $t->content_like(qr/README\.md/);
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
339
    $t->content_like(qr/kimoto1\@gitprep\.example/);
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
340
    $t->content_like(qr/Hello/);
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
341

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

            
simplify rename project
Yuki Kimoto authored on 2013-05-22
346
    # Settings page(has README)
cleanup
Yuki Kimoto authored on 2013-05-24
347
    $t->get_ok('/kimoto1/t2/settings');
348
    $t->content_like(qr/Settings/);
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
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
Yuki Kimoto authored on 2013-05-19
354
  }
cleanup
Yuki Kimoto authored on 2013-05-24
355
  
356
  note 'Project settings';
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
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
Yuki Kimoto authored on 2013-05-25
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...
Yuki Kimoto authored on 2013-05-25
377
      # Change description(t1)
add change description test
Yuki Kimoto authored on 2013-05-25
378
      $t->post_ok("/kimoto1/t1/settings?op=change-description", form => {description => 'あああ'});
379
      $t->content_like(qr/Description is saved/);
add default branch test
Yuki Kimoto authored on 2013-05-25
380
      $t->content_like(qr/あああ/);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
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
Yuki Kimoto authored on 2013-05-25
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
Yuki Kimoto authored on 2016-03-31
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...
Yuki Kimoto authored on 2016-04-21
403
        where => {user => $app->gitprep_api->get_user_row_id('kimoto1'), id => 't2'}
cleanup settings page logic
Yuki Kimoto authored on 2016-03-31
404
      )->value;
405
      is($changed, 'b1');
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
406
    }
add delete project test
Yuki Kimoto authored on 2013-05-25
407
    
408
    note 'Delete project';
409
    {
add fork test
Yuki Kimoto authored on 2013-05-25
410
      $t->post_ok('/kimoto1/t1/settings?op=delete-project');
411
      $t->content_like(qr/Repository t1 is deleted/);
add delete project test
Yuki Kimoto authored on 2013-05-25
412
      $t->get_ok('/kimoto1');
add fork test
Yuki Kimoto authored on 2013-05-25
413
      $t->content_unlike(qr/t1/);
add delete project test
Yuki Kimoto authored on 2013-05-25
414
    }
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
415
  }
add create repository tests
Yuki Kimoto authored on 2013-05-19
416
}
add fork test
Yuki Kimoto authored on 2013-05-25
417

            
418
note 'fork';
419
{
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
423

            
add fork test
Yuki Kimoto authored on 2013-05-25
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...
Yuki Kimoto authored on 2013-05-25
437
  $t->content_like(qr/いいい/);
add fork test
Yuki Kimoto authored on 2013-05-25
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...
Yuki Kimoto authored on 2013-05-29
445

            
add network test
Yuki Kimoto authored on 2013-05-29
446
note 'Network';
447
{
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
451

            
add network test
Yuki Kimoto authored on 2013-05-29
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...
Yuki Kimoto authored on 2013-05-29
468
note 'Delete branch';
469
{
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
473

            
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
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
Yuki Kimoto authored on 2013-05-29
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...
Yuki Kimoto authored on 2013-05-29
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
Yuki Kimoto authored on 2016-01-27
492
  $t->content_like(qr/Delete/);
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
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...
Yuki Kimoto authored on 2013-08-19
501

            
502
note 'import-branch';
503
{
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
507

            
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
508
  my $t = Test::Mojo->new($app);
509
  $t->ua->max_redirects(3);
510

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

            
515
  # Create project
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
518
  
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
546
  
add import branch tests
Yuki Kimoto authored on 2013-08-19
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...
Yuki Kimoto authored on 2013-08-19
569
}
add private repository and c...
Yuki Kimoto authored on 2013-11-18
570

            
571
note 'Private repository and collaborator';
572
{
573
  unlink $db_file;
574
  rmtree $rep_home;
575

            
fix some tests
Yuki Kimoto authored on 2016-04-21
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
Yuki Kimoto authored on 2016-04-14
579

            
add private repository and c...
Yuki Kimoto authored on 2013-11-18
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...
Yuki Kimoto authored on 2016-04-21
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...
Yuki Kimoto authored on 2013-11-18
593
  $t->content_like(qr/Success.*created/);
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
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...
Yuki Kimoto authored on 2013-11-18
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
Yuki Kimoto authored on 2016-03-31
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...
Yuki Kimoto authored on 2016-04-21
610
    where => {user => $app->gitprep_api->get_user_row_id('kimoto'), id => 't1'}
cleanup settings page logic
Yuki Kimoto authored on 2016-03-31
611
  )->value;
612
  is($is_private, 1);
add private repository and c...
Yuki Kimoto authored on 2013-11-18
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
}