@@ -22,8 +22,9 @@ Test::PAUSE::Web->setup;
2222subtest ' get' => sub {
2323 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
2424 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" );
2728 # note $t->content;
2829 }
2930};
@@ -36,8 +37,9 @@ subtest 'get: user with subdirs' => sub {
3637 $subdir -> make_path;
3738 $subdir -> child(" stuff.txt" )-> spew(" Foo" );
3839
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" );
4143 $t -> text_is(' select[name="pause99_add_uri_subdirscrl"] option[value="."]' , " ." ); # default
4244 $t -> text_is(' select[name="pause99_add_uri_subdirscrl"] option[value="test"]' , " test" );
4345 # note $t->content;
@@ -47,13 +49,14 @@ subtest 'get: user with subdirs' => sub {
4749subtest ' post: basic' => sub {
4850 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
4951 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 );
5154 my %form = %$http_upload ;
5255 my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
5356 ok !-f $file , " file to upload does not exist" ;
5457
5558 $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" );
5760 # note $t->content;
5861
5962 ok -f $file , " uploaded file exists" ;
@@ -70,15 +73,16 @@ subtest 'post: basic' => sub {
7073subtest ' post: under a new subdir' => sub {
7174 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
7275 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 );
7478 my %form = %$http_upload ;
7579 $form {pause99_add_uri_subdirtext } = " new_dir" ;
7680
7781 my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
7882 ok !-f $file , " file to upload does not exist" ;
7983
8084 $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" );
8286 # note $t->content;
8387
8488 ok -f $file , " uploaded file exists" ;
@@ -96,7 +100,8 @@ subtest 'post: under a new subdir' => sub {
96100subtest ' post: under a Perl6 subdir' => sub {
97101 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
98102 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 );
100105 my %form = %$http_upload ;
101106 $form {pause99_add_uri_subdirscrl } = " Perl6" ;
102107
@@ -109,7 +114,7 @@ subtest 'post: under a Perl6 subdir' => sub {
109114 ok !-f $file , " file to upload does not exist" ;
110115
111116 $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" );
113118 # note $t->content;
114119
115120 ok -f $file , " uploaded file exists" ;
@@ -125,15 +130,38 @@ subtest 'post: under a Perl6 subdir' => sub {
125130 }
126131};
127132
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+
128155subtest ' post: empty' => sub {
129156 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
130157 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 );
132160 my %form = %$http_upload ;
133161 $form {pause99_add_uri_httpupload } = [undef , ' index.html' ];
134162
135163 $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" );
137165 # note $t->content;
138166
139167 my $rows = $t -> mod_db-> select(' uris' , [' *' ], {
@@ -147,14 +175,15 @@ subtest 'post: empty' => sub {
147175subtest ' post: renamed' => sub {
148176 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
149177 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 );
151180 my %form = %$http_upload ;
152181 $form {pause99_add_uri_httpupload } = [" $Test::PAUSE::Web::AppRoot /htdocs/index.html" , ' html/index.html' ];
153182 my $file = $PAUSE::Config -> {INCOMING_LOC }." /index.html" ;
154183 ok !-f $file , " file to upload does not exist" ;
155184
156185 $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" );
158187 # note $t->content;
159188
160189 # renamed file exists
@@ -172,11 +201,12 @@ subtest 'post: renamed' => sub {
172201subtest ' post: uri' => sub {
173202 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
174203 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 );
176206 my %form = %$uri_upload ;
177207
178208 $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" );
180210 # note $t->content;
181211
182212 my $rows = $t -> mod_db-> select(' uris' , [' *' ], {
@@ -190,12 +220,13 @@ subtest 'post: uri' => sub {
190220subtest ' post: CHECKSUMS' => sub {
191221 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
192222 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 );
194225 my %form = %$http_upload ;
195226 $form {pause99_add_uri_httpupload } = [" $Test::PAUSE::Web::AppRoot /htdocs/index.html" , " CHECKSUMS" ],
196227
197228 $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" );
199230 $t -> text_like(' .error_message' => qr / Files with the name CHECKSUMS cannot be/ );
200231 # note $t->content;
201232
@@ -210,14 +241,15 @@ subtest 'post: CHECKSUMS' => sub {
210241subtest ' post: allow overwrite' => sub {
211242 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
212243 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 );
214246 my %form = %$http_upload ;
215247 my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
216248 ok !-f $file , " file to upload does not exists" ;
217249
218250 $t -> mod_dbh-> do(' TRUNCATE uris' );
219251 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" );
221253 # note $t->content;
222254
223255 # uploaded file exists
@@ -236,14 +268,15 @@ subtest 'post: allow overwrite' => sub {
236268subtest ' post: duplicate' => sub {
237269 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
238270 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 );
240273 my %form = %$http_upload ;
241274 $form {pause99_add_uri_httpupload } = [" $Test::PAUSE::Web::AppRoot /htdocs/index.html" , " index.tar.gz" ],
242275 my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
243276 ok !-f $file , " file to upload does not exist" ;
244277
245278 $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" );
247280 # note $t->content;
248281
249282 ok -f $file , " uploaded file exists" ;
@@ -255,7 +288,7 @@ subtest 'post: duplicate' => sub {
255288 });
256289 is @$rows => 1;
257290
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" );
259292 is $res -> code => 409;
260293 # note $t->content;
261294
@@ -273,13 +306,14 @@ subtest 'post: duplicate' => sub {
273306subtest ' post: to the site top, as various CPAN uploaders do/did' => sub {
274307 for my $test (Test::PAUSE::Web-> tests_for(' user' )) {
275308 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 );
277311 my %form = %$http_upload ;
278312 my $file = $PAUSE::Config -> {INCOMING_LOC }." /" .$form {pause99_add_uri_httpupload }[1];
279313 ok !-f $file , " file to upload does not exist" ;
280314
281315 $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" );
283317 # note $t->content;
284318
285319 ok -f $file , " uploaded file exists" ;
0 commit comments