@@ -22,8 +22,9 @@ Test::PAUSE::Web->setup;
22
22
subtest ' get' => sub {
23
23
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
24
24
my ($path , $user ) = @$test ;
25
- my $t = Test::PAUSE::Web-> new(user => $user );
26
- $t -> get_ok(" $path ?ACTION=add_uri" );
25
+ my $t = Test::PAUSE::Web-> new;
26
+ $t -> login(user => $user );
27
+ $t -> get_ok(" user/add_uri" );
27
28
# note $t->content;
28
29
}
29
30
};
@@ -36,8 +37,9 @@ subtest 'get: user with subdirs' => sub {
36
37
$subdir -> make_path;
37
38
$subdir -> child(" stuff.txt" )-> spew(" Foo" );
38
39
39
- my $t = Test::PAUSE::Web-> new(user => $user );
40
- $t -> get_ok(" $path ?ACTION=add_uri" );
40
+ my $t = Test::PAUSE::Web-> new;
41
+ $t -> login(user => $user );
42
+ $t -> get_ok(" /user/add_uri" );
41
43
$t -> text_is(' select[name="pause99_add_uri_subdirscrl"] option[value="."]' , " ." ); # default
42
44
$t -> text_is(' select[name="pause99_add_uri_subdirscrl"] option[value="test"]' , " test" );
43
45
# note $t->content;
@@ -47,13 +49,14 @@ subtest 'get: user with subdirs' => sub {
47
49
subtest ' post: basic' => sub {
48
50
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
49
51
my ($path , $user ) = @$test ;
50
- my $t = Test::PAUSE::Web-> new(user => $user );
52
+ my $t = Test::PAUSE::Web-> new;
53
+ $t -> login(user => $user );
51
54
my %form = %$http_upload ;
52
55
my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
53
56
ok !-f $file , " file to upload does not exist" ;
54
57
55
58
$t -> mod_dbh-> do(' TRUNCATE uris' );
56
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
59
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
57
60
# note $t->content;
58
61
59
62
ok -f $file , " uploaded file exists" ;
@@ -70,15 +73,16 @@ subtest 'post: basic' => sub {
70
73
subtest ' post: under a new subdir' => sub {
71
74
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
72
75
my ($path , $user ) = @$test ;
73
- my $t = Test::PAUSE::Web-> new(user => $user );
76
+ my $t = Test::PAUSE::Web-> new;
77
+ $t -> login(user => $user );
74
78
my %form = %$http_upload ;
75
79
$form {pause99_add_uri_subdirtext } = " new_dir" ;
76
80
77
81
my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
78
82
ok !-f $file , " file to upload does not exist" ;
79
83
80
84
$t -> mod_dbh-> do(' TRUNCATE uris' );
81
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
85
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
82
86
# note $t->content;
83
87
84
88
ok -f $file , " uploaded file exists" ;
@@ -96,7 +100,8 @@ subtest 'post: under a new subdir' => sub {
96
100
subtest ' post: under a Perl6 subdir' => sub {
97
101
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
98
102
my ($path , $user ) = @$test ;
99
- my $t = Test::PAUSE::Web-> new(user => $user );
103
+ my $t = Test::PAUSE::Web-> new;
104
+ $t -> login(user => $user );
100
105
my %form = %$http_upload ;
101
106
$form {pause99_add_uri_subdirscrl } = " Perl6" ;
102
107
@@ -109,7 +114,7 @@ subtest 'post: under a Perl6 subdir' => sub {
109
114
ok !-f $file , " file to upload does not exist" ;
110
115
111
116
$t -> mod_dbh-> do(' TRUNCATE uris' );
112
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
117
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
113
118
# note $t->content;
114
119
115
120
ok -f $file , " uploaded file exists" ;
@@ -125,15 +130,38 @@ subtest 'post: under a Perl6 subdir' => sub {
125
130
}
126
131
};
127
132
133
+ subtest ' post: move error' => sub {
134
+ for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
135
+ my ($path , $user ) = @$test ;
136
+ my $t = Test::PAUSE::Web-> new;
137
+ $t -> login(user => $user );
138
+ my %form = %$http_upload ;
139
+ rmtree($PAUSE::Config -> {INCOMING_LOC });
140
+
141
+ $t -> mod_dbh-> do(' TRUNCATE uris' );
142
+ $t -> post_ok(" /user/add_uri" , \%form , " Content-Type" => " form-data" );
143
+ $t -> text_like(' .error_message' => qr / Couldn't copy file/ );
144
+
145
+ my $rows = $t -> mod_db-> select(' uris' , [' *' ], {
146
+ userid => $user ,
147
+ uri => $form {pause99_add_uri_httpupload }[1],
148
+ });
149
+ is @$rows => 0;
150
+
151
+ mkpath($PAUSE::Config -> {INCOMING_LOC });
152
+ }
153
+ };
154
+
128
155
subtest ' post: empty' => sub {
129
156
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
130
157
my ($path , $user ) = @$test ;
131
- my $t = Test::PAUSE::Web-> new(user => $user );
158
+ my $t = Test::PAUSE::Web-> new;
159
+ $t -> login(user => $user );
132
160
my %form = %$http_upload ;
133
161
$form {pause99_add_uri_httpupload } = [undef , ' index.html' ];
134
162
135
163
$t -> mod_dbh-> do(' TRUNCATE uris' );
136
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
164
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
137
165
# note $t->content;
138
166
139
167
my $rows = $t -> mod_db-> select(' uris' , [' *' ], {
@@ -147,14 +175,15 @@ subtest 'post: empty' => sub {
147
175
subtest ' post: renamed' => sub {
148
176
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
149
177
my ($path , $user ) = @$test ;
150
- my $t = Test::PAUSE::Web-> new(user => $user );
178
+ my $t = Test::PAUSE::Web-> new;
179
+ $t -> login(user => $user );
151
180
my %form = %$http_upload ;
152
181
$form {pause99_add_uri_httpupload } = [" $Test::PAUSE::Web::AppRoot /htdocs/index.html" , ' html/index.html' ];
153
182
my $file = $PAUSE::Config -> {INCOMING_LOC }." /index.html" ;
154
183
ok !-f $file , " file to upload does not exist" ;
155
184
156
185
$t -> mod_dbh-> do(' TRUNCATE uris' );
157
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
186
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
158
187
# note $t->content;
159
188
160
189
# renamed file exists
@@ -172,11 +201,12 @@ subtest 'post: renamed' => sub {
172
201
subtest ' post: uri' => sub {
173
202
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
174
203
my ($path , $user ) = @$test ;
175
- my $t = Test::PAUSE::Web-> new(user => $user );
204
+ my $t = Test::PAUSE::Web-> new;
205
+ $t -> login(user => $user );
176
206
my %form = %$uri_upload ;
177
207
178
208
$t -> mod_dbh-> do(' TRUNCATE uris' );
179
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
209
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
180
210
# note $t->content;
181
211
182
212
my $rows = $t -> mod_db-> select(' uris' , [' *' ], {
@@ -190,12 +220,13 @@ subtest 'post: uri' => sub {
190
220
subtest ' post: CHECKSUMS' => sub {
191
221
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
192
222
my ($path , $user ) = @$test ;
193
- my $t = Test::PAUSE::Web-> new(user => $user );
223
+ my $t = Test::PAUSE::Web-> new;
224
+ $t -> login(user => $user );
194
225
my %form = %$http_upload ;
195
226
$form {pause99_add_uri_httpupload } = [" $Test::PAUSE::Web::AppRoot /htdocs/index.html" , " CHECKSUMS" ],
196
227
197
228
$t -> mod_dbh-> do(' TRUNCATE uris' );
198
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
229
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
199
230
$t -> text_like(' .error_message' => qr / Files with the name CHECKSUMS cannot be/ );
200
231
# note $t->content;
201
232
@@ -210,14 +241,15 @@ subtest 'post: CHECKSUMS' => sub {
210
241
subtest ' post: allow overwrite' => sub {
211
242
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
212
243
my ($path , $user ) = @$test ;
213
- my $t = Test::PAUSE::Web-> new(user => $user );
244
+ my $t = Test::PAUSE::Web-> new;
245
+ $t -> login(user => $user );
214
246
my %form = %$http_upload ;
215
247
my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
216
248
ok !-f $file , " file to upload does not exists" ;
217
249
218
250
$t -> mod_dbh-> do(' TRUNCATE uris' );
219
251
for (0 .. 1) {
220
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
252
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
221
253
# note $t->content;
222
254
223
255
# uploaded file exists
@@ -236,14 +268,15 @@ subtest 'post: allow overwrite' => sub {
236
268
subtest ' post: duplicate' => sub {
237
269
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
238
270
my ($path , $user ) = @$test ;
239
- my $t = Test::PAUSE::Web-> new(user => $user );
271
+ my $t = Test::PAUSE::Web-> new;
272
+ $t -> login(user => $user );
240
273
my %form = %$http_upload ;
241
274
$form {pause99_add_uri_httpupload } = [" $Test::PAUSE::Web::AppRoot /htdocs/index.html" , " index.tar.gz" ],
242
275
my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
243
276
ok !-f $file , " file to upload does not exist" ;
244
277
245
278
$t -> mod_dbh-> do(' TRUNCATE uris' );
246
- $t -> post_ok(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
279
+ $t -> post_ok(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
247
280
# note $t->content;
248
281
249
282
ok -f $file , " uploaded file exists" ;
@@ -255,7 +288,7 @@ subtest 'post: duplicate' => sub {
255
288
});
256
289
is @$rows => 1;
257
290
258
- my $res = $t -> post(" $path ?ACTION= add_uri" , \%form , " Content-Type" => " form-data" );
291
+ my $res = $t -> post(" /user/ add_uri" , \%form , " Content-Type" => " form-data" );
259
292
is $res -> code => 409;
260
293
# note $t->content;
261
294
@@ -273,13 +306,14 @@ subtest 'post: duplicate' => sub {
273
306
subtest ' post: to the site top, as various CPAN uploaders do/did' => sub {
274
307
for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
275
308
my ($path , $user ) = @$test ;
276
- my $t = Test::PAUSE::Web-> new(user => $user );
309
+ my $t = Test::PAUSE::Web-> new;
310
+ $t -> login(user => $user );
277
311
my %form = %$http_upload ;
278
312
my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
279
313
ok !-f $file , " file to upload does not exist" ;
280
314
281
315
$t -> mod_dbh-> do(' TRUNCATE uris' );
282
- $t -> post_ok(" $path " , \%form , " Content-Type" => " form-data" );
316
+ $t -> post_ok(" / " , \%form , " Content-Type" => " form-data" );
283
317
# note $t->content;
284
318
285
319
ok -f $file , " uploaded file exists" ;
0 commit comments