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