Fix, test, document
[catagits/Catalyst-Authentication-Credential-HTTP.git] / t / live_app.t
index fc07156..40e2ced 100644 (file)
@@ -14,13 +14,12 @@ BEGIN {
     }
       or plan skip_all =>
       "Test::WWW::Mechanize::Catalyst is needed for this test";
-    plan tests => 4;
 }
 use HTTP::Request;
 
 use Test::More;
-use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/;
-my $mech = Test::WWW::Mechanize::Catalyst->new;
+use Test::WWW::Mechanize::Catalyst;
+my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
 $mech->get("http://localhost/moose");
 is( $mech->status, 401, "status is 401" ) or die $mech->content;
 $mech->content_lacks( "foo", "no output" );
@@ -30,3 +29,18 @@ $mech->request($r);
 is( $mech->status, 200, "status is 200" );
 $mech->content_contains( "foo", "foo output" );
 
+AuthTestApp->get_auth_realm('test')->credential->no_unprompted_authorization_required(1);
+$mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
+$mech->get("http://localhost/moose");
+isnt( $mech->status, 401, "status isnt 401" ) or die $mech->content;
+
+AuthTestApp->get_auth_realm('test')->credential->no_unprompted_authorization_required(0);
+AuthTestApp->get_auth_realm('test')->credential->require_ssl(1);
+$mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
+$r = HTTP::Request->new( GET => "http://localhost/moose" );
+$r->authorization_basic(qw/foo s3cr3t/);
+$mech->request($r);
+is( $mech->status, 401, "status is 401" );
+
+done_testing;
+