gitprep / xt / user.t /
Newer Older
587 lines | 19.54kb
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
cleanup
Yuki Kimoto authored on 2013-05-24
320
    $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello'});
321
    $t->content_like(qr/Create a new repository on the command line/);
322
    $t->content_like(qr/t1\.git/);
323
    $t->content_like(qr/Hello/);
add git export file test
Yuki Kimoto authored on 2013-05-25
324
    ok(-f "$rep_home/kimoto1/t1.git/git-daemon-export-ok");
325
    ok(-f "$rep_home/kimoto1/t1.git/hooks/post-update");
add create repository tests
Yuki Kimoto authored on 2013-05-19
326

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

            
add create repository tests
Yuki Kimoto authored on 2013-05-19
333
    # Create repository(with readme)
cleanup
Yuki Kimoto authored on 2013-05-24
334
    $t->post_ok('/_new?op=create', form => {project => 't2', description => 'Hello', readme => 1});
335
    $t->content_like(qr/first commit/);
336
    $t->content_like(qr/t2\.git/);
default readme file is chang...
Yuki Kimoto authored on 2013-11-16
337
    $t->content_like(qr/README\.md/);
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
338
    $t->content_like(qr/kimoto1\@gitprep\.example/);
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
339
    $t->content_like(qr/Hello/);
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
340

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

            
simplify rename project
Yuki Kimoto authored on 2013-05-22
345
    # Settings page(has README)
cleanup
Yuki Kimoto authored on 2013-05-24
346
    $t->get_ok('/kimoto1/t2/settings');
347
    $t->content_like(qr/Settings/);
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
348

            
349
    # Create repository(with private)
350
    $t->post_ok('/_new?op=create', form => {project => 't_private', private => 1});
351
    $t->content_like(qr/t_private\.git/);
352
    $t->content_like(qr/icon-lock/);
add create repository tests
Yuki Kimoto authored on 2013-05-19
353
  }
cleanup
Yuki Kimoto authored on 2013-05-24
354
  
355
  note 'Project settings';
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
356
  {
357
    note 'Rename project';
358
    {
359
      # Empty
360
      $t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {});
361
      $t->content_like(qr/Repository name is empty/);
362
      
363
      # Invalid character
364
      $t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {'to-project' => '&'});
365
      $t->content_like(qr/Repository name contains invalid charactor/);
366
      
367
      # Rename project
368
      $t->post_ok('/kimoto1/t2/settings?op=rename-project', form => {'to-project' => 't3'});
369
      $t->content_like(qr/Repository name is renamed to t3/);
add change description test
Yuki Kimoto authored on 2013-05-25
370
      $t->post_ok('/kimoto1/t3/settings?op=rename-project', form => {'to-project' => 't2'});
371
      $t->content_like(qr/Repository name is renamed to t2/);
372
    }
373
    
374
    note 'Change description';
375
    {
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
376
      # Change description(t1)
add change description test
Yuki Kimoto authored on 2013-05-25
377
      $t->post_ok("/kimoto1/t1/settings?op=change-description", form => {description => 'あああ'});
add website URL settings. yo...
Yuki Kimoto authored on 2016-08-17
378
      $t->content_like(qr/Description is changed/);
add default branch test
Yuki Kimoto authored on 2013-05-25
379
      $t->content_like(qr/あああ/);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
380

            
381
      # Change description(t2)
382
      $t->post_ok("/kimoto1/t2/settings?op=change-description", form => {description => 'いいい'});
add website URL settings. yo...
Yuki Kimoto authored on 2016-08-17
383
      $t->content_like(qr/Description is changed/);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
384
      $t->content_like(qr/いいい/);
add default branch test
Yuki Kimoto authored on 2013-05-25
385
    }
386
    
387
    note 'Change default branch';
388
    {
389
      # Default branch default
390
      $t->get_ok('/kimoto1/t1/settings');
391
      $t->content_like(qr/master/);
392
      
393
      # Change default branch
394
      my $cmd = "git --git-dir=$rep_home/kimoto1/t2.git branch b1";
395
      system($cmd) == 0 or die "Can't execute git branch";
396
      $t->get_ok('/kimoto1/t2/settings');
397
      $t->content_like(qr/b1/);
cleanup settings page logic
Yuki Kimoto authored on 2016-03-31
398
      $t->post_ok("/kimoto1/t2/settings?op=save-settings", form => {'default-branch' => 'b1'});
399
      $t->content_like(qr/Settings is saved/);
400
      my $changed = $t->app->dbi->model('project')->select(
401
        'default_branch',
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
402
        where => {user => $app->gitprep_api->get_user_row_id('kimoto1'), id => 't2'}
cleanup settings page logic
Yuki Kimoto authored on 2016-03-31
403
      )->value;
404
      is($changed, 'b1');
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
405
    }
add delete project test
Yuki Kimoto authored on 2013-05-25
406
    
407
    note 'Delete project';
408
    {
add fork test
Yuki Kimoto authored on 2013-05-25
409
      $t->post_ok('/kimoto1/t1/settings?op=delete-project');
410
      $t->content_like(qr/Repository t1 is deleted/);
add delete project test
Yuki Kimoto authored on 2013-05-25
411
      $t->get_ok('/kimoto1');
add fork test
Yuki Kimoto authored on 2013-05-25
412
      $t->content_unlike(qr/t1/);
add delete project test
Yuki Kimoto authored on 2013-05-25
413
    }
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
414
  }
add create repository tests
Yuki Kimoto authored on 2013-05-19
415
}
add fork test
Yuki Kimoto authored on 2013-05-25
416

            
417
note 'fork';
418
{
fix some tests
Yuki Kimoto authored on 2016-04-21
419
  system("$FindBin::Bin/../setup_database", $db_file) == 0
420
    or die "Can't setup $db_file";
421
  my $app = Mojo::Server->new->load_app("$FindBin::Bin/../script/gitprep");
cleanup tests
Yuki Kimoto authored on 2016-04-14
422

            
add fork test
Yuki Kimoto authored on 2013-05-25
423
  my $t = Test::Mojo->new($app);
424
  $t->ua->max_redirects(3);
425
  
426
  # Don't logind
427
  $t->get_ok("/kimoto1/t2/fork");
428
  $t->content_like(qr/Users/);
429

            
430
  # Login as kimoto2
431
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
432
  
433
  # Fork kimoto1/t2
434
  $t->get_ok("/kimoto1/t2/fork");
435
  $t->content_like(qr#Repository is forked from /kimoto1/t2#);
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
436
  $t->content_like(qr/いいい/);
add fork test
Yuki Kimoto authored on 2013-05-25
437
  
438
  # Fork kimoto1/t2 again
439
  $t->get_ok("/kimoto1/t2/fork");
440
  $t->content_like(qr/forked from/);
441
  $t->content_like(qr#kimoto1/t2#);
442
  $t->content_unlike(qr/Repository is forked from/);
443
}
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
444

            
add network test
Yuki Kimoto authored on 2013-05-29
445
note 'Network';
446
{
fix some tests
Yuki Kimoto authored on 2016-04-21
447
  system("$FindBin::Bin/../setup_database", $db_file) == 0
448
    or die "Can't setup $db_file";
449
  my $app = Mojo::Server->new->load_app("$FindBin::Bin/../script/gitprep");
cleanup tests
Yuki Kimoto authored on 2016-04-14
450

            
add network test
Yuki Kimoto authored on 2013-05-29
451
  my $t = Test::Mojo->new($app);
452
  $t->ua->max_redirects(3);
453

            
454
  $t->get_ok("/kimoto1/t2/network");
455
  $t->content_like(qr/Members of the t2/);
456
  $t->content_like(qr/My branch.*kimoto1.*t2.*master/s);
457
  $t->content_like(qr/Member branch.*kimoto2.*t2.*master/s);
458
  
459
  note 'Graph';
460
  {
461
    $t->get_ok("/kimoto1/t2/network/graph/master...kimoto2/t2/master");
462
    $t->content_like(qr/Graph/);
463
    $t->content_like(qr/first commit/);
464
  }
465
}
466

            
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
467
note 'Delete branch';
468
{
fix some tests
Yuki Kimoto authored on 2016-04-21
469
  system("$FindBin::Bin/../setup_database", $db_file) == 0
470
    or die "Can't setup $db_file";
471
  my $app = Mojo::Server->new->load_app("$FindBin::Bin/../script/gitprep");
cleanup tests
Yuki Kimoto authored on 2016-04-14
472

            
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
473
  my $t = Test::Mojo->new($app);
474
  $t->ua->max_redirects(3);
475
  
476
  # No delete branch button
477
  $t->get_ok("/kimoto1/t2/branches");
478
  $t->content_like(qr/Branches/);
479
  $t->content_unlike(qr/Delete branch/);
add test
Yuki Kimoto authored on 2013-05-29
480
  
481
  # Can't delete branch when no login
482
  $t->post_ok('/kimoto1/t2/branches?op=delete', form => {branch => 'tmp_branch'})
483
    ->content_like(qr/Users/);
484
  
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
485

            
486
  # Login as kimoto1
487
  $t->post_ok('/_login?op=login', form => {id => 'kimoto1', password => 'a'});
488
  my $cmd = "git --git-dir=$rep_home/kimoto1/t2.git branch tmp_branch";
489
  system($cmd) == 0 or die "Can't execute git branch";
490
  $t->get_ok("/kimoto1/t2/branches");
improve branch design
Yuki Kimoto authored on 2016-01-27
491
  $t->content_like(qr/Delete/);
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
492
  $t->content_like(qr/tmp_branch/);
493
  
494
  # Delete branch
495
  $t->post_ok('/kimoto1/t2/branches?op=delete', form => {branch => 'tmp_branch'});
496
  $t->content_like(qr/Branch tmp_branch is deleted/);
497
  $t->get_ok('/kimoto1/t2/branches');
498
  $t->content_unlike(qr/tmp_branch/);
499
}
add import-branch authentica...
Yuki Kimoto authored on 2013-08-19
500

            
add private repository and c...
Yuki Kimoto authored on 2013-11-18
501
note 'Private repository and collaborator';
502
{
503
  unlink $db_file;
504
  rmtree $rep_home;
505

            
fix some tests
Yuki Kimoto authored on 2016-04-21
506
  system("$FindBin::Bin/../setup_database", $db_file) == 0
507
    or die "Can't setup $db_file";
508
  my $app = Mojo::Server->new->load_app("$FindBin::Bin/../script/gitprep");
cleanup tests
Yuki Kimoto authored on 2016-04-14
509

            
add private repository and c...
Yuki Kimoto authored on 2013-11-18
510
  my $t = Test::Mojo->new($app);
511
  $t->ua->max_redirects(3);
512

            
513
  # Create admin user
514
  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
515
  $t->content_like(qr/Login page/);
516

            
517
  # Login success
518
  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
519
  $t->content_like(qr/Admin/);
520
  
521
  # Create user
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
522
  $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
523
  $t->content_like(qr/Success.*created/);
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
524
  $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
525
  $t->content_like(qr/Success.*created/);
526

            
527
  # Login as kimoto
528
  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
529
  $t->get_ok('/')->content_like(qr/kimoto/);
530

            
531
  # Create repository
532
  $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1});
533
  $t->content_like(qr/README/);
534
  
535
  # Check private repository
cleanup settings page logic
Yuki Kimoto authored on 2016-03-31
536
  $t->post_ok("/kimoto/t1/settings?op=save-settings", form => {private => 1});
537
  $t->content_like(qr/Settings is saved/);
538
  my $is_private = $t->app->dbi->model('project')->select(
539
    'private',
fix user create and update b...
Yuki Kimoto authored on 2016-04-21
540
    where => {user => $app->gitprep_api->get_user_row_id('kimoto'), id => 't1'}
cleanup settings page logic
Yuki Kimoto authored on 2016-03-31
541
  )->value;
542
  is($is_private, 1);
add private repository and c...
Yuki Kimoto authored on 2013-11-18
543
  
544
  # Can access repository myself
545
  $t->get_ok("/kimoto/t1");
546
  $t->content_like(qr/README/);
547

            
548
  # Login as kimoto2
549
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
550
  $t->get_ok('/')->content_like(qr/kimoto2/);
551
  
552
  # Can't access private repository
553
  $t->get_ok("/kimoto/t1");
554
  $t->content_like(qr/t1 is private repository/);
555
  
556
  # Login as kimoto
557
  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
558
  $t->get_ok('/')->content_like(qr/kimoto/);
559
  
560
  # Add collaborator
561
  $t->post_ok("/kimoto/t1/settings/collaboration?op=add", form => {collaborator => 'kimoto2'});
562
  $t->content_like(qr/Collaborator kimoto2 is added/);
563
  
564
  # Login as kimoto2
565
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
566
  $t->get_ok('/')->content_like(qr/kimoto2/);
567
  
568
  # Can access private repository from collaborator
569
  $t->get_ok("/kimoto/t1");
570
  $t->content_like(qr/README/);
571

            
572
  # Login as kimoto
573
  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
574
  $t->get_ok('/')->content_like(qr/kimoto/);
575

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

            
580
  # Login as kimoto2
581
  $t->post_ok('/_login?op=login', form => {id => 'kimoto2', password => 'a'});
582
  $t->get_ok('/')->content_like(qr/kimoto2/);
583

            
584
  # Can't access private repository
585
  $t->get_ok("/kimoto/t1");
586
  $t->content_like(qr/t1 is private repository/);
587
}