this should not be added to required prereqs
[catagits/Catalyst-Authentication-Credential-HTTP.git] / t / live_app.t
CommitLineData
790f9ddb 1use strict;
2use warnings;
bd1101db 3
4use FindBin qw/$Bin/;
5use lib "$Bin/lib";
6
ed61ff6d 7use Test::More;
419d9af2 8use Test::Needs { 'Test::WWW::Mechanize::Catalyst' => '0.51' };
790f9ddb 9use HTTP::Request;
861c2f44 10
282361af 11my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
790f9ddb 12$mech->get("http://localhost/moose");
513d8ab6 13is( $mech->status, 401, "status is 401" ) or die $mech->content;
ed61ff6d 14$mech->content_lacks( "foo", "no output" );
790f9ddb 15my $r = HTTP::Request->new( GET => "http://localhost/moose" );
16$r->authorization_basic(qw/foo s3cr3t/);
ed61ff6d 17$mech->request($r);
18is( $mech->status, 200, "status is 200" );
19$mech->content_contains( "foo", "foo output" );
513d8ab6 20
282361af 21AuthTestApp->get_auth_realm('test')->credential->no_unprompted_authorization_required(1);
22$mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
23$mech->get("http://localhost/moose");
24isnt( $mech->status, 401, "status isnt 401" ) or die $mech->content;
25
26AuthTestApp->get_auth_realm('test')->credential->no_unprompted_authorization_required(0);
27AuthTestApp->get_auth_realm('test')->credential->require_ssl(1);
28$mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
29$r = HTTP::Request->new( GET => "http://localhost/moose" );
30$r->authorization_basic(qw/foo s3cr3t/);
31$mech->request($r);
32is( $mech->status, 401, "status is 401" );
33
34done_testing;
35