X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbasic.t;h=91f2dc9293280fa89eafb48a9a887929257d1cb1;hb=05512a6983c245f2a23f76a55561e6d6de2c7bb2;hp=a819115003b55ec60417c069280848c6a52e125a;hpb=031f556c9ad2c64f19b6feb03e65924d41dfafba;p=catagits%2FCatalyst-Authentication-Credential-HTTP.git diff --git a/t/basic.t b/t/basic.t index a819115..91f2dc9 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 24; +use Test::More tests => 28; use Test::MockObject::Extends; use Test::MockObject; use Test::Exception; @@ -113,3 +113,29 @@ is( $body, 'Authorization required.' ); like( ($res_headers->header('WWW-Authenticate'))[0], qr/realm="myrealm"/, "WWW-Authenticate header set: digest realm overridden"); like( ($res_headers->header('WWW-Authenticate'))[1], qr/realm="myrealm"/, "WWW-Authenticate header set: basic realm overridden"); +# Check authorization_required_message works +$req_headers->clear; +$res_headers->clear; +$c->clear; +{ + my $self = new_self( type => 'any', password_type => 'clear', + authorization_required_message => 'foobar' + ); + throws_ok { + $self->authenticate( $c, $realm ); + } qr/^ $Catalyst::DETACH $/x, "detached"; + is( $body, 'foobar', 'Body is supplied auth message'); +} + +$req_headers->clear; +$res_headers->clear; +$c->clear; +{ + my $self = new_self( type => 'any', password_type => 'clear', + authorization_required_message => undef + ); + throws_ok { + $self->authenticate( $c, $realm ); + } qr/^ $Catalyst::DETACH $/x, "detached"; + is( $body, undef, 'Body is not set - user overrode auth message'); +} \ No newline at end of file