Skip to content

Commit

Permalink
test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 23, 2013
1 parent c8ddc63 commit f6e43bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
28 changes: 14 additions & 14 deletions t/mojo/cookie.t
Expand Up @@ -179,7 +179,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse response cookie with invalid flag (RFC 6265)
Expand Down Expand Up @@ -209,7 +209,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse quoted response cookie (RFC 6265, alternative)
Expand All @@ -224,7 +224,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse quoted response cookie roundtrip (RFC 6265)
Expand All @@ -239,7 +239,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';
$cookies = Mojo::Cookie::Response->parse($cookies->[0]);
is $cookies->[0]->name, 'foo', 'right name';
Expand All @@ -249,7 +249,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse quoted response cookie roundtrip (RFC 6265, alternative)
Expand All @@ -264,7 +264,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';
$cookies = Mojo::Cookie::Response->parse($cookies->[0]);
is $cookies->[0]->name, 'foo', 'right name';
Expand All @@ -274,7 +274,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse quoted response cookie roundtrip (RFC 6265, another alternative)
Expand All @@ -289,7 +289,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';
$cookies = Mojo::Cookie::Response->parse($cookies->[0]);
is $cookies->[0]->name, 'foo', 'right name';
Expand All @@ -299,7 +299,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse quoted response cookie roundtrip (RFC 6265, yet another alternative)
Expand All @@ -314,7 +314,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';
$cookies = Mojo::Cookie::Response->parse($cookies->[0]);
is $cookies->[0]->name, 'foo', 'right name';
Expand All @@ -324,7 +324,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

# Parse response cookie without value (RFC 2965)
Expand All @@ -339,7 +339,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[0]->to_string,
'foo=; expires=Thu, 07 Aug 2008 07:07:59 GMT; domain=example.com;'
. ' path=/test; secure; Max-Age=60', 'right result';
Expand All @@ -355,7 +355,7 @@ is $cookies->[0]->path, '/test', 'right path';
is $cookies->[0]->max_age, 60, 'right max age value';
is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[0]->to_string,
'foo=; expires=Thu, 07 Aug 2008 07:07:59 GMT; domain=example.com;'
. ' path=/test; secure; Max-Age=60', 'right result';
Expand Down Expand Up @@ -385,7 +385,7 @@ is $cookies->[0]->max_age, 0, 'right max age value';
is $cookies->[0]->expires, 'Thu, 01 Jan 1970 00:00:00 GMT',
'right expires value';
is $cookies->[0]->expires->epoch, 0, 'right expires epoch value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->secure, 1, 'right secure flag';
is $cookies->[1], undef, 'no more cookies';

done_testing();
17 changes: 8 additions & 9 deletions t/mojo/transactor.t
Expand Up @@ -34,24 +34,23 @@ is $tx->req->url->path->to_string, 'foo%2Fbar', 'right path';
is $tx->req->method, 'GET', 'right method';

# POST with header
$tx = $t->tx(POST => 'https://mojolicio.us' => {Expect => 'nothing'});
$tx = $t->tx(POST => 'https://mojolicio.us' => {DNT => 1});
is $tx->req->url->to_abs, 'https://mojolicio.us', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->expect, 'nothing', 'right "Expect" value';
is $tx->req->headers->dnt, 1, 'right "DNT" value';

# POST with header and content
$tx
= $t->tx(POST => 'https://mojolicio.us' => {Expect => 'nothing'} => 'test');
$tx = $t->tx(POST => 'https://mojolicio.us' => {DNT => 1} => 'test');
is $tx->req->url->to_abs, 'https://mojolicio.us', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->expect, 'nothing', 'right "Expect" value';
is $tx->req->headers->dnt, 1, 'right "DNT" value';
is $tx->req->body, 'test', 'right content';

# DELETE with content
$tx = $t->tx(DELETE => 'https://mojolicio.us' => 'test');
is $tx->req->url->to_abs, 'https://mojolicio.us', 'right URL';
is $tx->req->method, 'DELETE', 'right method';
is $tx->req->headers->expect, undef, 'no "Expect" value';
is $tx->req->headers->dnt, undef, 'no "DNT" value';
is $tx->req->body, 'test', 'right content';

# PUT with custom content generator
Expand Down Expand Up @@ -420,10 +419,10 @@ $tx = $t->upgrade($tx);
ok $tx->is_websocket, 'is a WebSocket';

# WebSocket handshake with header
$tx = $t->websocket('wss://127.0.0.1:3000/echo' => {Expect => 'foo'});
$tx = $t->websocket('wss://127.0.0.1:3000/echo' => {DNT => 1});
is $tx->req->url->to_abs, 'https://127.0.0.1:3000/echo', 'right URL';
is $tx->req->method, 'GET', 'right method';
is $tx->req->headers->expect, 'foo', 'right "Expect" value';
is $tx->req->headers->dnt, 1, 'right "DNT" value';
is $tx->req->headers->connection, 'Upgrade', 'right "Connection" value';
ok $tx->req->headers->sec_websocket_key, 'has "Sec-WebSocket-Key" value';
ok !$tx->req->headers->sec_websocket_protocol,
Expand All @@ -449,7 +448,7 @@ $tx = $t->websocket('wss://127.0.0.1:3000/echo' => {DNT => 1} =>
['v1.bar.example.com', 'foo', 'v2.baz.example.com']);
is $tx->req->url->to_abs, 'https://127.0.0.1:3000/echo', 'right URL';
is $tx->req->method, 'GET', 'right method';
is $tx->req->headers->dnt, '1', 'right "DNT" value';
is $tx->req->headers->dnt, 1, 'right "DNT" value';
is $tx->req->headers->connection, 'Upgrade', 'right "Connection" value';
ok $tx->req->headers->sec_websocket_key, 'has "Sec-WebSocket-Key" value';
is $tx->req->headers->sec_websocket_protocol,
Expand Down
2 changes: 1 addition & 1 deletion t/mojolicious/app.t
Expand Up @@ -405,7 +405,7 @@ $t->get_ok('/plugin/camel_case')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')->content_is('Welcome aboard!');

# MojoliciousTestController::Foo::stage2
$t->get_ok('/staged' => {'X-Pass' => '1'})->status_is(200)
$t->get_ok('/staged' => {'X-Pass' => 1})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')->content_is('Welcome aboard!');

# MojoliciousTestController::Foo::stage1
Expand Down

0 comments on commit f6e43bd

Please sign in to comment.