Pour all my changes for the new auth framework on top of the module.
[catagits/Catalyst-Authentication-Credential-HTTP.git] / t / live_app.t
index 31ea9b7..99b02b2 100644 (file)
@@ -13,29 +13,45 @@ use HTTP::Request;
     package AuthTestApp;
     use Catalyst qw/
       Authentication
-      Authentication::Store::Minimal
-      Authentication::Credential::HTTP
       /;
     use Test::More;
-    our $users;
+    our %users;
+    __PACKAGE__->config(authentication => {
+        default_realm => 'test',
+        realms => {
+            test => {
+                store => { 
+                    class => 'Minimal',
+                    users => \%users,
+                },
+                credential => { 
+                    class => 'HTTP', 
+                    type  => 'basic',
+                },
+            },
+        },
+    });
+    sub auto : Private {
+        my ($self, $c) = @_;
+        $c->authenticate();
+    }
     sub moose : Local {
         my ( $self, $c ) = @_;
-        $c->authorization_required;
-        $c->res->body( $c->user->id );
+           $c->res->body( $c->user->id );
     }
-    __PACKAGE__->config->{authentication}{http}{type} = 'basic';
-    __PACKAGE__->config->{authentication}{users} = $users = {
+    %users = (
         foo => { password         => "s3cr3t", },
-    };
+    );
     __PACKAGE__->setup;
 }
 use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/;
 my $mech = Test::WWW::Mechanize::Catalyst->new;
 $mech->get("http://localhost/moose");
-is( $mech->status, 401, "status is 401" );
+is( $mech->status, 401, "status is 401" ) or die $mech->content;
 $mech->content_lacks( "foo", "no output" );
 my $r = HTTP::Request->new( GET => "http://localhost/moose" );
 $r->authorization_basic(qw/foo s3cr3t/);
 $mech->request($r);
 is( $mech->status, 200, "status is 200" );
 $mech->content_contains( "foo", "foo output" );
+