Move test apps out into test files, fixes tests as predicted
[catagits/Catalyst-Authentication-Credential-HTTP.git] / t / live_app.t
index 31ea9b7..3ccbece 100644 (file)
@@ -1,34 +1,17 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
+use FindBin;
+use lib "$FindBin::Bin/lib";
 use Test::More;
 BEGIN {
     eval { require Test::WWW::Mechanize::Catalyst }
       or plan skip_all =>
       "Test::WWW::Mechanize::Catalyst is needed for this test";
-    plan tests => 4;
+    plan tests => 5;
+    use_ok 'AuthTestApp' or die;
 }
 use HTTP::Request;
-{
-    package AuthTestApp;
-    use Catalyst qw/
-      Authentication
-      Authentication::Store::Minimal
-      Authentication::Credential::HTTP
-      /;
-    use Test::More;
-    our $users;
-    sub moose : Local {
-        my ( $self, $c ) = @_;
-        $c->authorization_required;
-        $c->res->body( $c->user->id );
-    }
-    __PACKAGE__->config->{authentication}{http}{type} = 'basic';
-    __PACKAGE__->config->{authentication}{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");
@@ -39,3 +22,4 @@ $r->authorization_basic(qw/foo s3cr3t/);
 $mech->request($r);
 is( $mech->status, 200, "status is 200" );
 $mech->content_contains( "foo", "foo output" );
+