11 use Plack::Middleware::Auth::Basic;
13 sub dispatch_request {
15 Plack::Middleware::Auth::Basic->new(
16 authenticator => sub {
17 @auth_args = @_; return $auth_result
22 [ 200, [ 'Content-type' => 'text/plain' ], [ 'Woo' ] ]
27 my $ta = TestApp->new;
29 my $res = $ta->run_test_request(GET => '/');
31 is($res->code, '401', 'Auth failed with no user/pass');
32 ok(!@auth_args, 'Auth callback never called with no user/pass');
34 $res = $ta->run_test_request(GET => 'bob:secret@/');
36 is($res->code, '401', 'Auth failed with bad user/pass');
37 is($auth_args[0], 'bob', 'Username passed ok');
38 is($auth_args[1], 'secret', 'Password passed ok');
43 $res = $ta->run_test_request(GET => '/');
45 is($res->code, '401', 'Auth failed with no user/pass');
46 ok(!@auth_args, 'Auth callback never called with no user/pass');
48 $res = $ta->run_test_request(GET => 'bob:secret@/');
50 is($res->code, '200', 'Auth succeeded with good user/pass');
51 is($auth_args[0], 'bob', 'Username passed ok');
52 is($auth_args[1], 'secret', 'Password passed ok');