Fix RT#31036
[catagits/Catalyst-Authentication-Credential-HTTP.git] / t / basic.t
index 35d733a..25f78fd 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
-use Test::More tests => 13;
+use Test::More tests => 15;
 use Test::MockObject::Extends;
 use Test::MockObject;
 use Test::Exception;
@@ -17,6 +17,10 @@ $req->set_always( headers => $req_headers );
 my $res = Test::MockObject->new;
 my $status;
 $res->mock(status => sub { $status = $_[1] });
+my $content_type;
+$res->mock(content_type => sub { $content_type = $_[1] });
+my $body;
+$res->mock(body => sub { $body = $_[1] });
 my $res_headers = HTTP::Headers->new;
 $res->set_always( headers => $res_headers );
 my $c = Test::MockObject::Extends->new( $m );
@@ -24,6 +28,7 @@ my $cache = Test::MockObject->new;
 $cache->mock(set => sub { shift->{$_[0]} = $_[1] });
 $cache->mock(get => sub { return shift->{$_[0]} });
 $c->mock(cache => sub { $cache });
+$c->mock(debug => sub { 0 });
 my @login_info;
 $c->mock( login => sub { shift; @login_info = @_; 1 } );
 $c->set_always( config => {} );
@@ -43,6 +48,9 @@ throws_ok {
     $c->authorization_required( realm => "foo" );
 } qr/^ $Catalyst::DETACH $/x, "detached on no authorization required with bad auth";
 is( $status, 401, "401 status code" );
+is( $content_type, 'text/plain' );
+is( $body, 'Authorization required.' );
 like( ($res_headers->header('WWW-Authenticate'))[0], qr/^Digest/, "WWW-Authenticate header set: digest");
 like( ($res_headers->header('WWW-Authenticate'))[1], qr/^Basic/, "WWW-Authenticate header set: basic");
-like( ($res_headers->header('WWW-Authenticate'))[1], qr/realm=foo/, "WWW-Authenticate header set: basic with realm");
+like( ($res_headers->header('WWW-Authenticate'))[1], qr/realm="foo"/, "WWW-Authenticate header set: basic with realm");
+