File: cgi2.t

package info (click to toggle)
libapache2-mod-perl2 2.0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 12,016 kB
  • sloc: perl: 97,771; ansic: 14,493; makefile: 51; sh: 18
file content (61 lines) | stat: -rw-r--r-- 1,413 bytes parent folder | download | duplicates (7)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;
use Apache2::Build ();

my $build = Apache2::Build->build_config;

use constant HAVE_LWP => have_lwp();

my $tests = 4;
$tests += 1 if HAVE_LWP;

plan tests => $tests, need
    need_min_module_version(CGI => 3.08);

my $module = 'TestModules::cgi2';
my $location = '/' . Apache::TestRequest::module2path($module);

my($res, $str);

sok {
    my $url = "$location?PARAM=2";
    $res = GET $url;
    $str = $res->content;
    t_cmp($str, "ok 2", "GET $url");
};

sok {
    my $content = 'PARAM=%33';
    $str = POST_BODY $location, content => $content;
    t_cmp($str, "ok 3", "POST $location\n$content");
};

if (HAVE_LWP) {
    sok {
        t_client_log_warn_is_expected(4)
            if $] < 5.008 && require CGI && $CGI::VERSION < 3.06;
        $str = UPLOAD_BODY $location, content => 4;
        t_cmp($str, "ok 4", 'file upload');
    };
}

sok {
    my $header = 'Content-type';
    $res = GET $location;
    t_cmp($res->header($header),
          qr{^text/test-output},
          "$header header");
};

sok {
    my $header = 'X-Perl-Module';
    $res = GET $location;
    t_cmp($res->header($header),
          $module,
          "$header header");
};