Apache2-Translation
view release on metacpan or search on metacpan
t/011directives.t view on Meta::CPAN
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' );
}
SKIP: {
skip "Need JSON::XS or YAML to test Apache2::Translation::Config", 1
unless( need_module( 'JSON::XS' ) or need_module( 'YAML' ) );
my $text=GET_BODY( '/econf' );
my $x;
unless( eval 'require JSON::XS' and
$x=eval {JSON::XS::decode_json($text)} ) {
( run in 1.917 second using v1.01-cache-2.11-cpan-39bf76dae61 )