Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated compat tests

  • Loading branch information...
commit e0926d860e1d04128ca86fd7bc7f1ee29ea88948 1 parent 144efeb
sugama authored
View
33 MANIFEST
@@ -2,10 +2,43 @@ Changes
lib/Mojolicious/Plugin/PlackMiddleware.pm
Makefile.PL
MANIFEST
+Mojolicious-Plugin-PlackMiddleware-0.23.tar.gz
+MYMETA.json
+MYMETA.yml
README.pod
t/00_load.t
t/01_basic.t
+t/01_pertial.t
+t/02_basic.t
+t/03_basic2.t
+t/dispatcher_lite_app.t
+t/group_lite_app.t
+t/lite_app.t
+t/mws/error_document.t
+t/mws/errors/404.html
+t/mws/errors/500.html
+t/mws/jsonp.t
t/public/css.css
+t/public/hello.txt
+t/public/hello2.txt
+t/public_dev/hello.txt
+t/templates/23.html.epl
+t/templates/dies_too.html.ep
+t/templates/encoding.koi8-r.ep
+t/templates/exception.html.epl
+t/templates/exception.testing.html.ep
+t/templates/foo/bar.rss.ep
+t/templates/foo/bar/index.html.epl
+t/templates/foo/index.html.xpl
+t/templates/foo/yada.html.ep
+t/templates/layouts/default.html.epl
+t/templates/layouts/green.html.epl
+t/templates/not_found.testing.html.ep
+t/templates/simple.html.pod
+t/templates/syntaxerror.html.epl
+t/templates/withblock.txt.epl
+t/templates/withlayout.html.epl
+t/websocket_lite_app.t
xt/memory_leak.t
xt/perlcritic.t
xt/perlcriticrc
View
14 MANIFEST.bak 100755 → 100644
@@ -0,0 +1,14 @@
+Changes
+lib/Mojolicious/Plugin/PlackMiddleware.pm
+Makefile.PL
+MANIFEST
+README.pod
+t/00_load.t
+t/01_basic.t
+t/public/css.css
+xt/memory_leak.t
+xt/perlcritic.t
+xt/perlcriticrc
+xt/pod.t
+xt/podcoverage.t
+xt/podspell.t
View
27 t/dispatcher_lite_app.t
@@ -3,18 +3,31 @@ use Mojo::Base -strict;
# Disable Bonjour, IPv6 and libev
BEGIN {
$ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1;
- $ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
+ $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
-use Test::More tests => 15;
+use Test::More tests => 21;
# "Just once I'd like to eat dinner with a celebrity who isn't bound and
# gagged."
+use Mojo::Message::Response;
use Mojolicious::Lite;
use Test::Mojo;
plugin plack_middleware => [];
+# Internal redirect
+hook around_dispatch => sub {
+ my ($next, $self) = @_;
+ $next->();
+ if ($self->res->code == 404) {
+ $self->req->url->path($self->param('wrap') ? '/wrap/again' : '/');
+ delete $self->stash->{$_} for keys %{$self->stash};
+ $self->tx->res(Mojo::Message::Response->new);
+ $next->();
+ }
+};
+
# Wrap whole application
hook around_dispatch => sub {
my ($next, $self) = @_;
@@ -62,8 +75,14 @@ $t->get_ok('/custom?a=works+too')->status_is(205)->content_is('works too');
# GET /custom_too
$t->get_ok('/custom_too')->status_is(200)->content_is('this works too');
-# GET /wrap
+# GET /wrap (first wrapper)
$t->get_ok('/wrap')->status_is(200)->content_is('Wrapped!');
-# GET /wrap/again
+# GET /wrap/again (second wrapper)
$t->get_ok('/wrap/again')->status_is(200)->content_is('Wrapped again!');
+
+# GET /not_found (internal redirect to root)
+$t->get_ok('/not_found')->status_is(200)->content_is('works');
+
+# GET /not_found (internal redirect to second wrapper)
+$t->get_ok('/not_found?wrap=1')->status_is(200)->content_is('Wrapped again!');
View
2  t/group_lite_app.t
@@ -5,7 +5,7 @@ use utf8;
# Disable Bonjour, IPv6 and libev
BEGIN {
$ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1;
- $ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
+ $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
use Test::More tests => 154;
View
122 t/lite_app.t
@@ -4,12 +4,12 @@ use utf8;
# Disable Bonjour, IPv6 and libev
BEGIN {
- $ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1;
- $ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
$ENV{MOJO_MODE} = 'development';
+ $ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1;
+ $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
-use Test::More tests => 721;
+use Test::More tests => 703;
# "Wait you're the only friend I have...
# You really want a robot for a friend?
@@ -249,7 +249,8 @@ get '/inline/ep/partial' => sub {
get '/source' => sub {
my $self = shift;
my $file = $self->param('fail') ? 'does_not_exist.txt' : '../lite_app.t';
- $self->render_static($file)
+ $self->render('this_does_not_ever_exist')
+ or $self->render_static($file)
or $self->render_text('does not exist!', status => 404);
};
@@ -338,9 +339,6 @@ get '/layout' => sub {
# POST /template
post '/template' => 'index';
-# GET /memorized
-get '/memorized' => 'memorized';
-
# * /something
any '/something' => sub {
my $self = shift;
@@ -365,8 +363,8 @@ post '/bar/:test' => {test => 'default'} => sub {
$self->render_text($self->stash('test'));
};
-# GET /firefox/*
-get '/firefox/:stuff' => (agent => qr/Firefox/) => sub {
+# PATCH /firefox/*
+patch '/firefox/:stuff' => (agent => qr/Firefox/) => sub {
my $self = shift;
$self->render_text($self->url_for('foxy', stuff => 'foo'));
} => 'foxy';
@@ -541,6 +539,13 @@ get '/url_with/:foo' => sub {
$self->render(text => $self->url_with(foo => 'bar')->to_abs);
};
+# GET /dynamic/inline
+my $dynamic_inline = 1;
+get '/dynamic/inline' => sub {
+ my $self = shift;
+ $self->render(inline => 'dynamic inline ' . $dynamic_inline++);
+};
+
# Oh Fry, I love you more than the moon, and the stars,
# and the POETIC IMAGE NUMBER 137 NOT FOUND
my $t = Test::Mojo->new;
@@ -900,6 +905,10 @@ my $source = $t->tx->local_address;
$t->get_ok('/0', {'X-Forwarded-For' => '192.168.2.2, 192.168.2.1'})
->status_is(200)->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
+# GET /0 ("X-Forwarded-HTTPS")
+$t->get_ok('/0', {'X-Forwarded-HTTPS' => 1})->status_is(200)
+ ->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
+
# GET /0 (reverse proxy with "X-Forwarded-For")
{
local $ENV{MOJO_REVERSE_PROXY} = 1;
@@ -908,28 +917,11 @@ $t->get_ok('/0', {'X-Forwarded-For' => '192.168.2.2, 192.168.2.1'})
->content_like(qr#http\://localhost\:\d+/0\-192\.168\.2\.1\-0#);
}
-# GET /0 ("X-Forwarded-Host")
-$t->get_ok('/0', {'X-Forwarded-Host' => 'mojolicio.us:8080'})->status_is(200)
- ->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
-
-# GET /0 (reverse proxy with "X-Forwarded-Host")
-{
- local $ENV{MOJO_REVERSE_PROXY} = 1;
- $t->get_ok('/0', {'X-Forwarded-Host' => 'mojolicio.us:8080'})
- ->status_is(200)->content_is("http://mojolicio.us:8080/0-$source-0");
-}
-
-# GET /0 ("X-Forwarded-HTTPS" and "X-Forwarded-Host")
-$t->get_ok('/0',
- {'X-Forwarded-HTTPS' => 1, 'X-Forwarded-Host' => 'mojolicio.us'})
- ->status_is(200)->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
-
-# GET /0 (reverse proxy with "X-Forwarded-HTTPS" and "X-Forwarded-Host")
+# GET /0 (reverse proxy with "X-Forwarded-HTTPS")
{
local $ENV{MOJO_REVERSE_PROXY} = 1;
- $t->get_ok('/0',
- {'X-Forwarded-HTTPS' => 1, 'X-Forwarded-Host' => 'mojolicio.us'})
- ->status_is(200)->content_is("https://mojolicio.us/0-$source-0");
+ $t->get_ok('/0', {'X-Forwarded-HTTPS' => 1})->status_is(200)
+ ->content_like(qr#https\://localhost\:\d+/0\-$source\-0#);
}
# DELETE /inline/epl
@@ -972,6 +964,9 @@ $t->get_ok('/foo_relaxed/')->status_is(404);
# GET /foo_wildcard/123
$t->get_ok('/foo_wildcard/123')->status_is(200)->content_is('123');
+# GET /foo_wildcard/IQ==%0A
+$t->get_ok('/foo_wildcard/IQ==%0A')->status_is(200)->content_is("IQ==\x0a");
+
# GET /foo_wildcard
$t->get_ok('/foo_wildcard/')->status_is(404);
@@ -1041,30 +1036,6 @@ $t->post_ok('/template')->status_is(200)
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is('Just works!');
-# GET /memorized
-$t->get_ok('/memorized')->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr/\d+a\d+b\d+c\d+\nd\d+\ne\d+/);
-my $memorized = $t->tx->res->body;
-
-# GET /memorized
-$t->get_ok('/memorized')->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is($memorized);
-
-# GET /memorized
-$t->get_ok('/memorized')->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is($memorized);
-
-# GET /memorized (expired)
-sleep 2;
-$t->get_ok('/memorized')->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr/\d+a\d+b\d+c\d+\nd\d+\ne\d+/)->content_isnt($memorized);
-
# GET /something
$t->get_ok('/something')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
@@ -1125,14 +1096,14 @@ $t->get_ok('/layout')->status_is(200)
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is("LayoutYea baby! with layout\n");
-# GET /firefox
-$t->get_ok('/firefox/bar', {'User-Agent' => 'Firefox'})->status_is(200)
+# PATCH /firefox
+$t->patch_ok('/firefox/bar', {'User-Agent' => 'Firefox'})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_is('/firefox/foo');
-# GET /firefox
-$t->get_ok('/firefox/bar', {'User-Agent' => 'Explorer'})->status_is(404)
+# PATCH /firefox
+$t->patch_ok('/firefox/bar', {'User-Agent' => 'Explorer'})->status_is(404)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->content_like(qr/Oops!/);
@@ -1277,8 +1248,8 @@ $t->get_ok('/redirect_callback')->status_is(301)
$t->get_ok('/static_render')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => 30)
- ->content_is('Hello Mojo from a static file!');
+ ->header_is('Content-Length' => 31)
+ ->content_is("Hello Mojo from a static file!\n");
# GET /redirect_named (with redirecting enabled in user agent)
$t->ua->max_redirects(3);
@@ -1309,8 +1280,8 @@ $t->get_ok('/koi8-r')->status_is(200)
$t->get_ok('/hello.txt')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 30)
- ->content_is('Hello Mojo from a static file!');
+ ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 31)
+ ->content_is("Hello Mojo from a static file!\n");
# GET /hello.txt (partial static file)
$t->get_ok('/hello.txt', {'Range' => 'bytes=2-8'})->status_is(206)
@@ -1407,8 +1378,16 @@ EOF
$t->get_ok('/url_with/foo?foo=bar')->status_is(200)
->content_like(qr|http\://localhost\:\d+/url_with/bar\?foo\=bar|);
+# GET /dynamic/inline
+$t->get_ok('/dynamic/inline')->status_is(200)
+ ->content_is("dynamic inline 1\n");
+
+# GET /dynamic/inline (again)
+$t->get_ok('/dynamic/inline')->status_is(200)
+ ->content_is("dynamic inline 2\n");
+
# User agent timer
-$tua->ioloop->one_tick('0.1');
+$tua->ioloop->one_tick;
is $timer,
"/root.html\n/root.html\n/root.html\n/root.html\n/root.html\nworks!",
'right content';
@@ -1438,25 +1417,6 @@ text!
@@ template.txt.epl
<div id="foo">Redirect works!</div>
-@@ memorized.html.ep
-<%= memorize begin =%>
-<%= time =%>
-<% end =%>
-<%= memorize begin =%>
- <%= 'a' . time =%>
-<% end =%><%= memorize begin =%>
-<%= 'b' . time =%>
-<% end =%>
-<%= memorize test => begin =%>
-<%= 'c' . time =%>
-<% end =%>
-<%= memorize expiry => {expires => time + 1} => begin %>
-<%= 'd' . time =%>
-<% end =%>
-<%= memorize {expires => time + 1} => begin %>
-<%= 'e' . time =%>
-<% end =%>
-
@@ test(test)(\Qtest\E)(.html.ep
<%= $self->match->endpoint->name %>
View
2  t/public/hello.txt
@@ -1 +1 @@
-Hello Mojo from a static file!
+Hello Mojo from a static file!
View
2  t/public_dev/hello.txt
@@ -1 +1 @@
-Hello Mojo from a development static file!
+Hello Mojo from a development static file!
View
2  t/templates/23.html.epl
@@ -1,3 +1,3 @@
%# "Facts are meaningless.
%# You could use facts to prove anything that’s even remotely true!"
-%= 20 + 3
+%= 20 + 3
View
2  t/templates/exception.testing.html.ep
@@ -1,4 +1,4 @@
%# "You told Bart to kiss that girl?
%# Why not encourage him to knock her out and drag her to a cave?
%# Second base? Oh, Bart is a little too young for that."
-Testing <%= $exception->message %>!
+Testing <%= $exception->message %>!
View
2  t/templates/foo/bar/index.html.epl
@@ -1,3 +1,3 @@
%# "She is well traveled, and I don't mean she travels a lot."
% my $c = shift;
-Hello Mojo from the other template <%= $c->url_for %>!
+Hello Mojo from the other template <%= $c->url_for %>!
View
2  t/templates/foo/index.html.xpl
@@ -2,4 +2,4 @@
%# you can't pretend that didn't bring us closer together."
% my $c = shift;
% $c->stash(handler => 'epl');
-Hello Mojo from the template <%= $c->url_for %>! <%= $c->stash('msg') %>
+Hello Mojo from the template <%= $c->url_for %>! <%= $c->stash('msg') %>
View
2  t/templates/layouts/default.html.epl
@@ -7,4 +7,4 @@
<body>
<%= $self->render_partial(template => '23') %><%= $self->render_content %>
</body>
-</html>
+</html>
View
2  t/templates/layouts/green.html.epl
@@ -8,4 +8,4 @@
<body>
Same old in green <%= $self->render_content %>
</body>
-</html>
+</html>
View
2  t/templates/not_found.testing.html.ep
@@ -2,4 +2,4 @@
%# Jews don't believe in Hell.
%# No Hell! Thank you kid, you made my day.
%# *heads over to the Gaza Strip Club*"
-Testing not found!
+Testing not found!
View
2  t/templates/syntaxerror.html.epl
@@ -1,4 +1,4 @@
%# "Lisa, if the Bible has taught us nothing else, and it hasn't,
%# it's that girls should stick to girls sports,
%# such as hot oil wrestling and foxy boxing and such."
-% {
+% {
View
2  t/templates/withlayout.html.epl
@@ -1,3 +1,3 @@
%# "I guess I could part with one doomsday device and still be feared."
% shift->stash(layout => 'green');
-Seems to work!
+Seems to work!
View
6 t/websocket_lite_app.t
@@ -7,7 +7,7 @@ use utf8;
# Disable Bonjour, IPv6 and libev
BEGIN {
$ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1;
- $ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
+ $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
use Test::More tests => 91;
@@ -38,8 +38,8 @@ get '/plain' => {text => 'Nothing to see here!'};
# WebSocket /push
websocket '/push' => sub {
my $self = shift;
- my $id = Mojo::IOLoop->recurring('0.5' => sub { $self->send('push') });
- $self->on(finish => sub { Mojo::IOLoop->drop($id) });
+ my $id = Mojo::IOLoop->recurring(0.5 => sub { $self->send('push') });
+ $self->on(finish => sub { Mojo::IOLoop->remove($id) });
};
# WebSocket /unicode
Please sign in to comment.
Something went wrong with that request. Please try again.