From: Yuval Kogman Date: Mon, 5 Dec 2005 10:49:42 +0000 (+0000) Subject: Fix unit test for Credential::HTTP X-Git-Tag: v0.11~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9914dd2ced7c8935c55abda1f5bf8468ff768e4;hp=0914298e67babb131596ff9d7317b737a0c1ec6a;p=catagits%2FCatalyst-Authentication-Credential-HTTP.git Fix unit test for Credential::HTTP --- diff --git a/lib/Catalyst/Plugin/Authentication/Credential/HTTP.pm b/lib/Catalyst/Plugin/Authentication/Credential/HTTP.pm index 2efb00f..9db318c 100644 --- a/lib/Catalyst/Plugin/Authentication/Credential/HTTP.pm +++ b/lib/Catalyst/Plugin/Authentication/Credential/HTTP.pm @@ -8,6 +8,7 @@ use warnings; use String::Escape (); use URI::Escape (); +use Catalyst (); our $VERSION = "0.01"; diff --git a/t/basic.t b/t/basic.t index 84d6822..9060dc1 100644 --- a/t/basic.t +++ b/t/basic.t @@ -3,9 +3,10 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 11; use Test::MockObject::Extends; use Test::MockObject; +use Test::Exception; use HTTP::Headers; @@ -32,7 +33,6 @@ my $c = Test::MockObject::Extends->new( $m ); my @login_info; $c->mock( login => sub { shift; @login_info = @_; 1 } ); -$c->set_false( "detach" ); $c->set_always( config => {} ); $c->set_always( req => $req ); $c->set_always( res => $res ); @@ -45,14 +45,16 @@ $req_headers->authorization_basic( qw/foo bar/ ); ok( $c->authenticate_http, "auth successful with header"); is_deeply( \@login_info, [qw/foo bar/], "login info delegated"); -ok( $c->authorization_required, "authorization required with successful authentication"); -ok( !$c->called("detach"), "didnt' detach"); +lives_ok { + $c->authorization_required +} "no detach on authorization required with successful authentication"; $req_headers->clear; $c->clear; -ok( !$c->authorization_required, "authorization required with bad authentication"); -$c->called_ok("detach", "detached"); +throws_ok { + $c->authorization_required; +} qr/^ $Catalyst::DETACH $/x, "detached on no authorization required with bad auth"; is( $status, 401, "401 status code" ); like( $res_headers->www_authenticate, qr/^Basic/, "WWW-Authenticate header set");