Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unit test for 5e57e2f

  • Loading branch information...
commit 7c84e5e8c9c7a80893373bbd7362fd41ef450033 1 parent a393fce
@miyagawa miyagawa authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 t/Plack-Middleware/urlmap_env.t
View
32 t/Plack-Middleware/urlmap_env.t
@@ -0,0 +1,32 @@
+use strict;
+use Test::More;
+use Plack::App::URLMap;
+use Plack::Test;
+use HTTP::Request::Common;
+
+use Plack::Middleware::Auth::Basic;
+use Plack::Middleware::AccessLog;
+
+my $app1 = sub {
+ my $env = shift;
+ return [ 200, ['Content-Type' => 'text/plain'], ["Hello $env->{REMOTE_USER}"] ];
+};
+
+$app1 = Plack::Middleware::Auth::Basic->wrap($app1, authenticator => sub { 1 });
+
+my $app = Plack::App::URLMap->new;
+$app->map("/foo" => $app1);
+
+my $line;
+$app = Plack::Middleware::AccessLog->wrap($app, logger => sub { $line = shift });
+
+test_psgi app => $app, client => sub {
+ my $cb = shift;
+
+ my $res = $cb->(GET "http://localhost/foo", Authorization => "Basic YWRtaW46czNjcjN0");
+ is $res->content, 'Hello admin';
+
+ like $line, qr/ admin /;
+};
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.