Changeset 17540
- Timestamp:
- 08/12/08 21:34:04 (5 years ago)
- Location:
- lang/perl/HTTP-Engine/trunk/t/010_core
- Files:
-
- 6 modified
-
request-absolute_uri.t (modified) (1 diff)
-
request-readbody.t (modified) (3 diffs)
-
request-secure.t (modified) (1 diff)
-
request_builder_dummy.t (modified) (1 diff)
-
response-cookie.t (modified) (2 diffs)
-
responsewriter-with_io.t (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTP-Engine/trunk/t/010_core/request-absolute_uri.t
r13758 r17540 1 use strict; 2 use warnings; 1 3 use Test::Base; 2 4 use HTTP::Engine::Request; -
lang/perl/HTTP-Engine/trunk/t/010_core/request-readbody.t
r17502 r17540 20 20 do { 21 21 local $@; 22 eval { 23 $req->raw_body; 24 }; 22 eval { $req->raw_body }; 25 23 like $@, qr/read initialization must set input_handle/; 26 24 }; 27 25 do { 28 26 local $@; 29 eval { 30 $req->request_builder->_io_read; 31 }; 27 eval { $req->request_builder->_io_read }; 32 28 like $@, qr/no handle/; 33 29 }; 34 35 36 30 }; 37 31 … … 52 46 ); 53 47 my $state = $req->_read_state; 54 $req->request_builder->_read_all($state); 55 56 $tmp->seek(0, File::Temp::SEEK_SET); 57 $state->{read_position} = 0; 58 59 do { 60 my $read_all = \&HTTP::Engine::RequestBuilder::_read_all; 61 no warnings 'redefine'; 62 local *HTTP::Engine::RequestBuilder::_read_all = sub { 63 $read_all->(@_); 64 $state->{read_position}--; 65 }; 66 local $@; 67 eval { $req->request_builder->_read_to_end($state); }; 68 like $@, qr/Wrong Content-Length value: 3/; 48 my $reset = sub { 49 $tmp->seek(0, File::Temp::SEEK_SET); 50 $state->{read_position} = 0; 69 51 }; 70 52 71 $tmp->seek(0, File::Temp::SEEK_SET);72 $state->{read_position} = 0;73 53 74 do { 75 my $read_all = \&HTTP::Engine::RequestBuilder::_read_all; 76 no warnings 'redefine'; 77 local *HTTP::Engine::RequestBuilder::_read_all = sub { 78 $read_all->(@_); 79 $state->{read_position}++; 80 }; 81 local $@; 82 eval { $req->request_builder->_read_to_end($state); }; 83 like $@, qr/Premature end of request body, -1 bytes remaining/; 84 }; 54 $req->request_builder->_read_all($state); 55 $reset->(); 85 56 86 $tmp->seek(0, File::Temp::SEEK_SET); 87 $state->{read_position} = 0; 57 read_to_end($req, $state, sub { $state->{read_position}-- }, 'Wrong Content-Length value: 3'); 58 $reset->(); 59 60 read_to_end($req, $state, sub { $state->{read_position}++ }, 'Premature end of request body, -1 bytes remaining'); 61 $reset->(); 88 62 89 63 do { … … 95 69 }; 96 70 }; 71 72 sub read_to_end { 73 my($req, $state, $code, $re) = @_; 74 my $read_all = \&HTTP::Engine::RequestBuilder::_read_all; 75 no warnings 'redefine'; 76 local *HTTP::Engine::RequestBuilder::_read_all = sub { 77 $read_all->(@_); 78 $code->(); 79 }; 80 local $@; 81 eval { $req->request_builder->_read_to_end($state); }; 82 like $@, qr/\Q$re\E/, $re; 83 } -
lang/perl/HTTP-Engine/trunk/t/010_core/request-secure.t
r17480 r17540 1 1 use strict; 2 2 use warnings; 3 use Test:: More;3 use Test::Base; 4 4 use HTTP::Engine::Request; 5 5 use HTTP::Engine::RequestBuilder; 6 6 7 plan tests => 18;7 plan tests => 3*blocks; 8 8 9 $ENV{HTTP_HOST} = 'example.com'; 10 11 do { 12 local $ENV{HTTPS} = 'ON'; 13 check(1, 'https://example.com/', 443); 14 }; 15 16 do { 17 local $ENV{HTTPS} = 'OFF'; 18 check(0, 'http://example.com/', 80); 19 }; 20 21 do { 22 check(0, 'http://example.com/', 80); 23 }; 24 25 do { 26 local $ENV{HTTPS} = 'ON'; 27 local $ENV{SERVER_PORT} = 8443; 28 check(1, 'https://example.com:8443/', 8443); 29 }; 30 31 do { 32 local $ENV{SERVER_PORT} = 443; 33 check(1, 'https://example.com/', 443); 34 }; 35 36 do { 37 local $ENV{SERVER_PORT} = 80; 38 check(0, 'http://example.com/', 80); 39 }; 40 41 sub check { 42 my($is_secure, $uri, $port) = @_; 9 filters { env => ['yaml'] }; 10 run { 11 my $block = shift; 43 12 my $req = HTTP::Engine::Request->new( 44 13 request_builder => HTTP::Engine::RequestBuilder->new, 45 14 ); 46 is $req->secure , $is_secure; 47 is $req->uri , $uri; 48 is $req->uri->port, $port; 15 local %ENV = %{ $block->env }; 16 my $secure = $req->secure; 17 is qq{"$secure"} , $block->is_secure; 18 is $req->uri , $block->uri; 19 is $req->uri->port, $block->port; 49 20 } 50 21 22 __END__ 23 24 === 25 --- env 26 HTTP_HOST: example.com 27 HTTPS: ON 28 --- is_secure: "1" 29 --- uri: https://example.com/ 30 --- port: 443 31 32 === 33 --- env 34 HTTP_HOST: example.com 35 HTTPS: OFF 36 --- is_secure: "0" 37 --- uri: http://example.com/ 38 --- port: 80 39 40 === 41 --- env 42 HTTP_HOST: example.com 43 --- is_secure: "0" 44 --- uri: http://example.com/ 45 --- port: 80 46 47 === 48 --- env 49 HTTP_HOST: example.com 50 HTTPS: ON 51 SERVER_PORT: 8443 52 --- is_secure: "1" 53 --- uri: https://example.com:8443/ 54 --- port: 8443 55 56 === 57 --- env 58 HTTP_HOST: example.com 59 SERVER_PORT: 443 60 --- is_secure: "1" 61 --- uri: https://example.com/ 62 --- port: 443 63 64 === 65 --- env 66 HTTP_HOST: example.com 67 SERVER_PORT: 80 68 --- is_secure: "0" 69 --- uri: http://example.com/ 70 --- port: 80 -
lang/perl/HTTP-Engine/trunk/t/010_core/request_builder_dummy.t
r17293 r17540 9 9 is (HTTP::Engine::RequestBuilder::Dummy->_build_raw_body, ''); 10 10 11 local $@; 12 eval { HTTP::Engine::RequestBuilder::Dummy->_build_http_body }; 13 like $@, qr/^HTTP::Body not supported with dummy request builder/; 11 do { 12 local $@; 13 eval { HTTP::Engine::RequestBuilder::Dummy->_build_http_body }; 14 like $@, qr/^HTTP::Body not supported with dummy request builder/; 15 }; 14 16 15 local $@; 16 eval { HTTP::Engine::RequestBuilder::Dummy->_build_read_state }; 17 like $@, qr/^Dummy request has no read state, can't parse HTTP::Body/; 17 do { 18 local $@; 19 eval { HTTP::Engine::RequestBuilder::Dummy->_build_read_state }; 20 like $@, qr/^Dummy request has no read state, can't parse HTTP::Body/; 21 }; 18 22 19 23 is_deeply (HTTP::Engine::RequestBuilder::Dummy->_build_connection_info, {}); -
lang/perl/HTTP-Engine/trunk/t/010_core/response-cookie.t
r17446 r17540 11 11 my $res = HTTP::Engine::Response->new(); 12 12 $res->cookies({ 13 'Foo'=> CGI::Simple::Cookie->new(13 Foo => CGI::Simple::Cookie->new( 14 14 -name => 'Foo', 15 15 -value => 'foo', … … 26 26 secure => 1, 27 27 }, 28 'ID'=> CGI::Simple::Cookie->new(28 ID => CGI::Simple::Cookie->new( 29 29 -name => 'ID', 30 30 -value => 'TKSK', -
lang/perl/HTTP-Engine/trunk/t/010_core/responsewriter-with_io.t
r17526 r17540 31 31 __END__ 32 32 33 === 33 === normal io 34 34 --- input 35 35 my $writer = HTTP::Engine::ResponseWriter->new( … … 64 64 OK! 65 65 66 === 66 === dummy io 67 67 --- input 68 68 my $writer = HTTP::Engine::ResponseWriter->new( … … 94 94 bless 95 95 96 === 96 === big size 97 97 --- input 98 98 my $writer = HTTP::Engine::ResponseWriter->new( … … 130 130 ".('dummy'x5000) 131 131 132 === 132 === no io 133 133 --- input 134 134 my $writer = HTTP::Engine::ResponseWriter->new( … … 159 159 OK! 160 160 161 === 161 === broken writer 162 162 --- input 163 163 my $writer = HTTP::Engine::ResponseWriter->new(
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)