Apache2-Translation
view release on metacpan or search on metacpan
t/011directives.t view on Meta::CPAN
22 k /conf/2 0 0 Config: ['TestHandlerConfig 2']
23 k /conf/3 0 0 Config: ['TestHandlerConfig 3', '/path']
24 k /proxy 0 0 Proxy: 'http://'.join(':', $r->get_server_name, $r->get_server_port).'/tstp'.$MATCHED_PATH_INFO
25 k /cgi2 0 0 Config: 'AllowOverride AuthConfig', 'Options FollowSymLinks'
26 k /cgi2 0 1 Config: 'SetHandler cgi-script'
27 k /cgi2 0 2 File: $r->document_root.$MATCHED_PATH_INFO
28 k /cgi3 0 0 Config: 'AllowOverride Options', 'Options FollowSymLinks'
29 k /cgi3 0 1 Config: 'SetHandler cgi-script'
30 k /cgi3 0 2 File: $r->document_root.$MATCHED_PATH_INFO
31 k /error 0 0 Redirect: '/tsthnd'
32 k /redr/1 0 0 Redirect: 'otto/1'
33 k /redr/2 0 0 Redirect: '/otto/2'
34 k /call 0 0 Call: qw!sub 1!
35 k /call2 0 0 Key: 'k2'
36 k /call2 0 1 Call: qw!sub 2!
37 k /cgi4 0 0 Cgiscript: $r->document_root.$MATCHED_PATH_INFO
38 k /perl4 0 0 Perlscript: $r->document_root.$MATCHED_PATH_INFO
39 k /minfo 0 0 Perlhandler: 'TestHandler::meminfo'
40 k /econf 0 0 Perlhandler: sub {require Apache2::Translation::Config; goto &Apache2::Translation::Config::handler;}
41 k /fixup 0 0 Perlhandler: sub {my $r=$_[0]; $r->content_type("text/plain"); my @n=$r->notes->get("fixup_add"); $r->print("@n"); 0;}
42 k /fixup 0 1 Fixup: $r->notes->add("fixup_add", "1")
43 k /fixup 0 2 Fixup: $r->notes->add("fixup_add", "2")
44 k /fixup 0 3 Fixup: $r->notes->add("fixup_add", "3")
45 k /html 0 0 Doc: 'text/html', 'HTML'
46 k /txt0 0 0 Doc: 'TXT'
47 k /txt1 0 0 Doc: 'text/plain', 'TXT'
100 k sub 0 0 Do: $r->notes->{n1}=$ARGV[0]
101 k sub 0 1 Perlhandler: sub {$_[0]->print($_[0]->notes->{n1}.'/'.$_[0]->notes->{n2}); 0}
102 * sub 0 0 Do: $r->notes->{n2}=$ARGV[0]
103 * sub 0 1 Perlhandler: sub {$_[0]->print($_[0]->notes->{n1}.'/'.$_[0]->notes->{n2}); 0}
EOD
update_db;
t_write_file( $documentroot.'/ok.html', 'OK' );
t_write_perl_script( $documentroot.'/script.pl', 'print "Content-Type: text/plain\n\n".($ENV{MOD_PERL}||$ENV{GATEWAY_INTERFACE});' );
ok t_cmp GET_BODY( '/ok.html' ), 'OK', n '/ok.html';
SKIP: {
skip "Need alias module", 1 unless( need_module( 'alias' ) );
ok t_cmp GET_BODY( '/alias/ok.html' ), 'OK', n '/alias/ok.html';
}
ok t_cmp GET_BODY( '/file/ok.html' ), 'OK', n '/file/ok.html';
SKIP: {
skip "Need cgi module", 2 unless( need_module( 'cgi' ) or need_module( 'cgid' ) );
ok t_cmp GET_BODY( '/cgi/script.pl' ), qr!^CGI/!, n '/cgi/script.pl';
ok t_cmp GET_BODY( '/cgi4/script.pl' ), qr!^CGI/!, n '/cgi4/script.pl';
}
ok t_cmp GET_BODY( '/perl/script.pl' ), qr!^mod_perl/!, n '/perl/script.pl';
ok t_cmp GET_BODY( '/perl4/script.pl' ), qr!^mod_perl/!, n '/perl4/script.pl';
t_client_log_warn_is_expected();
ok t_cmp GET_BODY( '/tsthnd' ), 'TestHandler', n '/tsthnd';
t_client_log_warn_is_expected(2);
ok t_cmp GET_BODY( '/tstm' ), 'TestModule', n '/tstm';
ok t_cmp GET_BODY( '/tstsub' ), 'TestModule', n '/tstsub';
ok t_cmp GET_BODY( '/tstp/path/info' ), '/path/info', n '/tstp/path/info';
ok t_cmp GET_BODY( '/conf/1' ), '/conf/1', n '/conf/1';
ok t_cmp GET_BODY( '/conf/2' ), '/', n '/conf/2';
ok t_cmp GET_BODY( '/conf/3' ), '/path', n '/conf/3';
SKIP: {
skip "Need proxy and proxy_http modules", 1 unless( need_module( ['proxy','proxy_http'] ) );
t_client_log_warn_is_expected();
ok t_cmp GET_BODY( '/proxy/path/info' ), '/path/info', n '/proxy/path/info';
}
SKIP: {
skip "Need cgi module", 2 unless( need_module( 'cgi' ) or need_module( 'cgid' ) );
t_write_file( $documentroot.'/.htaccess', "Options ExecCGI\n" );
t_client_log_error_is_expected();
ok t_cmp GET_RC( '/cgi2/script.pl' ), 500, n '/cgi2/script.pl';
t_start_error_log_watch;
my $body=GET_BODY( '/cgi3/script.pl' );
my @lines=t_finish_error_log_watch;
if(grep /\.htaccess: Option ExecCGI not allowed here/, @lines) {
warn "\n\n# WARNING: Your httpd is buggy.\n# See http://www.gossamer-threads.com/lists/apache/dev/327770#327770\n\n";
ok 1, n '/cgi3/script.pl';
} else {
ok t_cmp $body, qr!^CGI/!, n '/cgi3/script.pl';
}
}
my $resp=GET( '/error' );
ok t_cmp $resp->code, 302, n '/error: code==302';
ok t_cmp $resp->header('Location'),
'http://'.Apache::TestRequest::hostport.'/tsthnd',
n '/error: Location==http://'.Apache::TestRequest::hostport.'/tsthnd';
$resp=GET( '/not_found' );
ok t_cmp $resp->code, 302, n '/not_found: code==302';
ok t_cmp $resp->header('Location'),
'http://'.Apache::TestRequest::hostport.'/tsthnd',
n '/not_found: Location==http://'.Apache::TestRequest::hostport.'/tsthnd';
$resp=GET( '/redr/1' );
ok t_cmp $resp->code, 302, n '/redr/1: code==302';
ok t_cmp $resp->header('Location'),
'http://'.Apache::TestRequest::hostport.'/redr/otto/1',
n '/redr/1: Location==http://'.Apache::TestRequest::hostport.'/redr/otto/1';
$resp=GET( '/redr/2' );
ok t_cmp $resp->code, 302, n '/redr/2: code==302';
ok t_cmp $resp->header('Location'),
'http://'.Apache::TestRequest::hostport.'/otto/2',
n '/redr/2: Location==http://'.Apache::TestRequest::hostport.'/otto/2';
ok t_cmp GET_BODY( '/call' ), '1/', n '/call';
ok t_cmp GET_BODY( '/call2' ), '/2', n '/call2';
ok t_cmp GET_BODY( '/fixup' ), '1 2 3', n '/fixup';
$resp=GET( '/html' );
ok t_cmp $resp->content, 'HTML', n '/html body';
ok t_cmp $resp->header('Content-Type'), 'text/html', n '/html content_type';
$resp=GET( '/txt0' );
ok t_cmp $resp->content, 'TXT', n '/txt0 body';
ok t_cmp $resp->header('Content-Type'), 'text/plain', n '/txt0 content_type';
$resp=GET( '/txt1' );
ok t_cmp $resp->content, 'TXT', n '/txt1 body';
ok t_cmp $resp->header('Content-Type'), 'text/plain', n '/txt1 content_type';
SKIP: {
skip "Need Linux::Smaps to report meminfo", 0 unless( need_module( 'Linux::Smaps' ) );
t_debug GET_BODY( '/minfo' );
}
( run in 0.553 second using v1.01-cache-2.11-cpan-5735350b133 )