File: 110.bad-upload.t

package info (click to toggle)
libcgi-simple-perl 1.282-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 604 kB
  • sloc: perl: 1,885; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!perl

use strict;
use warnings;

use Test::More;
Test::More->builder->no_ending( 1 );
use Config;
use File::Spec;
use CGI::Simple;

$| = 1;

plan skip_all => "fork not available on this platform"
 unless $Config{d_fork};

eval { require HTTP::Request::Common; };

plan skip_all => 'HTTP::Request::Common not available' if $@;

plan tests => 1;

my $req = HTTP::Request::Common::POST(
  '/dummy_location',
  Content_Type => 'form-data',
  Content      => [
    test_file =>
     [ File::Spec->catfile( split /\//, "t/test_file.txt" ) ],
  ]
);

# Useful in simulating an upload.
$ENV{REQUEST_METHOD} = 'POST';
$ENV{CONTENT_TYPE}   = 'multipart/form-data';
$ENV{CONTENT_LENGTH} = $req->content_length;

if ( open( CHILD, "|-" ) ) {
  print CHILD $req->content;
  close CHILD;
  exit 0;
}

my $q = CGI::Simple->new;
is( $q->cgi_error, undef, "CGI::Simple can handle this" );