Dancer2-Plugin-HTTP-Auth-Extensible
view release on metacpan or search on metacpan
t/30-authenticate_Basic.t view on Meta::CPAN
test_psgi $app, sub {
my $cb = shift;
my $req = HTTP::Request->new( GET => '/auth');
$req->authorization_basic ( 'foo', 'bar');
my $res = $cb->( $req );
is (
$res->code,
401,
'Status 401: without proper credentials'
);
is (
$res->headers->header('WWW-Authenticate'),
qq|Basic realm="some_realm"|,
'HTTP-field: WWW-Authentication without proper credentials'
);
isnt ( # negative testing, we should not get this content
$res->content,
qq|Access granted for default realm|,
'Delivering: without proper credentials'
);
};
test_psgi $app, sub {
my $cb = shift;
my $req = HTTP::Request->new( GET => '/auth');
$req->authorization_basic ( 'dave', 'beer');
my $res = $cb->( $req );
is (
$res->code,
200,
'Status 200: with the right credentials'
);
isnt ( # negative testing, we should not be required to authenticate
$res->headers->header('WWW-Authenticate'),
qq|Basic realm="some_realm"|,
'HTTP-field: WWW-Authentication with the right credentials'
);
is (
$res->content,
qq|Access granted for default realm|,
'Delivering: with the right credentials'
);
};
#
# Roles
#
test_psgi $app, sub {
my $cb = shift;
my $req = HTTP::Request->new( GET => '/beer');
( run in 0.253 second using v1.01-cache-2.11-cpan-4d50c553e7e )