Epic cleanup and code shuffle in tests to avoid warnings
Tomas Doran [Fri, 16 Oct 2009 01:28:16 +0000 (01:28 +0000)]
20 files changed:
Changes
t/lib/AuthRealmTestApp.pm
t/lib/AuthRealmTestApp/Controller/Root.pm [new file with mode: 0644]
t/lib/AuthRealmTestAppCompat.pm
t/lib/AuthRealmTestAppCompat/Controller/Root.pm [new file with mode: 0644]
t/lib/AuthRealmTestAppProgressive.pm
t/lib/AuthRealmTestAppProgressive/Controller/Root.pm [new file with mode: 0644]
t/lib/AuthSessionTestApp.pm
t/lib/AuthSessionTestApp/Controller/Root.pm [new file with mode: 0644]
t/lib/AuthTestApp.pm
t/lib/AuthTestApp/Controller/Root.pm [new file with mode: 0644]
t/lib/RemoteTestApp1.pm
t/lib/RemoteTestApp1/Controller/Root.pm [new file with mode: 0644]
t/lib/RemoteTestApp2.pm
t/lib/RemoteTestApp2/Controller/Root.pm [new file with mode: 0644]
t/live_app.t
t/live_app_realms_progressive.t
t/live_app_remote1.t
t/live_app_remote2.t
t/live_app_session.t

diff --git a/Changes b/Changes
index c27f5bd..e45f669 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for Perl extension Catalyst::Plugin::Authentication
 
+     - Move root actions out of applcation class in tests to remove
+       warnings in the latest Catalyst.
      - Add AUTOLOAD method to the default user class so that methods are
        delegated down onto the underlieing user object retrieved from
        the store (if present)
index bc70351..dfc47c0 100644 (file)
@@ -25,69 +25,7 @@ our $admins = {
     }
 };
 
-sub moose : Local {
-       my ( $self, $c ) = @_;
-
-       ok(!$c->user, "no user");
-
-    while ( my ($user, $info) = each %$members ) {
-        
-        ok( 
-            $c->authenticate( 
-                { username => $user, password => $info->{password} }, 
-                'members' 
-            ), 
-            "user $user authentication" 
-        );
-
-        # check existing realms
-        ok( $c->user_in_realm('members'), "user in members realm");
-        ok(!$c->user_in_realm('admins'),  "user not in admins realm");
-
-        # check an invalid realm
-        ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
-
-        # check if we've got the right user
-        is( $c->user, $info, "user object is in proper place");
-
-        $c->logout;
-
-           # sanity check
-        ok(!$c->user, "no more user after logout");
-
-    }
-
-    while ( my ($user, $info) = each %$admins ) {
-        
-        ok( 
-            $c->authenticate( 
-                { username => $user, password => $info->{password} }, 
-                'admins' 
-            ), 
-            "user $user authentication" 
-        );
-
-        # check existing realms
-        ok(!$c->user_in_realm('members'), "user not in members realm");
-        ok( $c->user_in_realm('admins'),  "user in admins realm");
-
-        # check an invalid realm
-        ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
-
-        # check if we've got the right user
-        is( $c->user, $info, "user object is in proper place");
-
-        $c->logout;
-
-           # sanity check
-        ok(!$c->user, "no more user after logout");
-
-    }
-
-       $c->res->body( "ok" );
-}
-
-__PACKAGE__->config->{'Plugin::Authentication'} = {  
+__PACKAGE__->config('Plugin::Authentication' => {
     default_realm => 'members',
     realms => {
         members => {
@@ -98,7 +36,7 @@ __PACKAGE__->config->{'Plugin::Authentication'} = {
             },
             store => {
                 class => 'Minimal',
-                users => $members             
+                users => $members
             }
         },
         admins => {
@@ -109,10 +47,13 @@ __PACKAGE__->config->{'Plugin::Authentication'} = {
             },
             store => {
                 class => 'Minimal',
-                users => $admins               
+                users => $admins
             }
         }
     }
-};
+});
 
 __PACKAGE__->setup;
+
+1;
+
diff --git a/t/lib/AuthRealmTestApp/Controller/Root.pm b/t/lib/AuthRealmTestApp/Controller/Root.pm
new file mode 100644 (file)
index 0000000..347f3d6
--- /dev/null
@@ -0,0 +1,74 @@
+package AuthRealmTestApp::Controller::Root;
+use warnings;
+use strict;
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config(namespace => '');
+
+use Test::More;
+use Test::Exception;
+
+sub moose : Local {
+       my ( $self, $c ) = @_;
+
+       ok(!$c->user, "no user");
+
+    while ( my ($user, $info) = each %$AuthRealmTestApp::members ) {
+
+        ok(
+            $c->authenticate(
+                { username => $user, password => $info->{password} },
+                'members'
+            ),
+            "user $user authentication"
+        );
+
+        # check existing realms
+        ok( $c->user_in_realm('members'), "user in members realm");
+        ok(!$c->user_in_realm('admins'),  "user not in admins realm");
+
+        # check an invalid realm
+        ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
+
+        # check if we've got the right user
+        is( $c->user, $info, "user object is in proper place");
+
+        $c->logout;
+
+           # sanity check
+        ok(!$c->user, "no more user after logout");
+
+    }
+
+    while ( my ($user, $info) = each %$AuthRealmTestApp::admins ) {
+
+        ok(
+            $c->authenticate(
+                { username => $user, password => $info->{password} },
+                'admins'
+            ),
+            "user $user authentication"
+        );
+
+        # check existing realms
+        ok(!$c->user_in_realm('members'), "user not in members realm");
+        ok( $c->user_in_realm('admins'),  "user in admins realm");
+
+        # check an invalid realm
+        ok(!$c->user_in_realm('foobar'), "user not in foobar realm");
+
+        # check if we've got the right user
+        is( $c->user, $info, "user object is in proper place");
+
+        $c->logout;
+
+           # sanity check
+        ok(!$c->user, "no more user after logout");
+
+    }
+
+       $c->res->body( "ok" );
+}
+
+1;
+
index 8ff5389..6c40ccd 100644 (file)
@@ -1,6 +1,7 @@
 package AuthRealmTestAppCompat;
 use warnings;
 use strict;
+use base qw/Catalyst/;
 
 ### using A::Store::minimal with new style realms
 ### makes the app blow up, since c::p::a::s::minimal
@@ -13,35 +14,13 @@ use Catalyst qw/
     Authentication::Store::Minimal
 /;
 
-use Test::More;
-use Test::Exception;
-
 our $members = {
     bob => {
         password => "s00p3r"
     },
 };
 
-sub moose : Local {
-       my ( $self, $c ) = @_;
-
-    while ( my ($user, $info) = each %$members ) {
-        
-        my $ok = eval {
-            $c->authenticate( 
-                { username => $user, password => $info->{password} }, 
-                'members' 
-            ), 
-        };
-        
-        ok( !$@,                "Test did not die: $@" );
-        ok( $ok,                "user $user authentication" );
-    }
-
-       $c->res->body( "ok" );
-}
-
-__PACKAGE__->config->{'Plugin::Authentication'} = {  
+__PACKAGE__->config('Plugin::Authentication' => {
     default_realm => 'members',
         members => {
             credential => {
@@ -54,7 +33,9 @@ __PACKAGE__->config->{'Plugin::Authentication'} = {
                 users => $members,
             }
         },
-    
-};
+});
 
 __PACKAGE__->setup;
+
+1;
+
diff --git a/t/lib/AuthRealmTestAppCompat/Controller/Root.pm b/t/lib/AuthRealmTestAppCompat/Controller/Root.pm
new file mode 100644 (file)
index 0000000..9083896
--- /dev/null
@@ -0,0 +1,31 @@
+package AuthRealmTestAppCompat::Controller::Root;
+use warnings;
+use strict;
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config( namespace => '' );
+
+use Test::More;
+use Test::Exception;
+
+sub moose : Local {
+       my ( $self, $c ) = @_;
+
+    while ( my ($user, $info) = each %$AuthRealmTestAppCompat::members ) {
+
+        my $ok = eval {
+            $c->authenticate(
+                { username => $user, password => $info->{password} },
+                'members'
+            ),
+        };
+
+        ok( !$@,                "Test did not die: $@" );
+        ok( $ok,                "user $user authentication" );
+    }
+
+       $c->res->body( "ok" );
+}
+
+1;
+
index 23f12d1..3d205eb 100644 (file)
@@ -1,6 +1,7 @@
 package AuthRealmTestAppProgressive;
 use warnings;
 use strict;
+use base qw/Catalyst/;
 
 ### using A::Store::minimal with new style realms
 ### makes the app blow up, since c::p::a::s::minimal
@@ -13,9 +14,6 @@ use Catalyst qw/
     Authentication::Store::Minimal
 /;
 
-use Test::More;
-use Test::Exception;
-
 our %members = (
     'members' => {
         bob => { password => "s00p3r" }
@@ -25,7 +23,7 @@ our %members = (
     },
 );
 
-__PACKAGE__->config->{'Plugin::Authentication'} = {
+__PACKAGE__->config('Plugin::Authentication' => {
     default_realm => 'progressive',
     progressive => {
         class  => 'Progressive',
@@ -53,25 +51,9 @@ __PACKAGE__->config->{'Plugin::Authentication'} = {
             users => $members{members},
         }
     },
-};
-
-sub progressive : Local {
-       my ( $self, $c ) = @_;
-
-    foreach my $realm ( keys %members ) {
-        while ( my ( $user, $info ) = each %{$members{$realm}} ) {
-            my $ok = eval {
-                $c->authenticate(
-                    { username => $user, password => $info->{password} },
-                ); 
-            };
-            ok( !$@, "authentication passed." );
-            ok( $ok, "user authenticated" );
-            ok( $c->user_in_realm($realm), "user in proper realm" );
-        }
-    }
-       $c->res->body( "ok" );
-}
+});
 
 __PACKAGE__->setup;
 
+1;
+
diff --git a/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm b/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm
new file mode 100644 (file)
index 0000000..62f89b4
--- /dev/null
@@ -0,0 +1,30 @@
+package AuthRealmTestAppProgressive::Controller::Root;
+use warnings;
+use strict;
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config(namespace => '');
+
+use Test::More;
+use Test::Exception;
+
+sub progressive : Local {
+       my ( $self, $c ) = @_;
+
+    foreach my $realm ( keys %AuthRealmTestAppProgressive::members ) {
+        while ( my ( $user, $info ) = each %{$AuthRealmTestAppProgressive::members{$realm}} ) {
+            my $ok = eval {
+                $c->authenticate(
+                    { username => $user, password => $info->{password} },
+                ); 
+            };
+            ok( !$@, "authentication passed." );
+            ok( $ok, "user authenticated" );
+            ok( $c->user_in_realm($realm), "user in proper realm" );
+        }
+    }
+       $c->res->body( "ok" );
+}
+
+1;
+
index ad6b862..e1db298 100644 (file)
@@ -5,6 +5,10 @@ sub for_session { $_[0]->id }
 sub store { $_[0]->{store} }
 
 package AuthSessionTestApp;
+use strict;
+use warnings;
+use base qw/Catalyst/;
+
 use Catalyst qw/
        Session
        Session::Store::Dummy
@@ -15,83 +19,18 @@ use Catalyst qw/
        Authentication::Credential::Password
 /;
 
-use Test::More;
-use Test::Exception;
-
-use Digest::MD5 qw/md5/;
-
-our $users;
-
-sub moose : Local {
-       my ( $self, $c ) = @_;
-
-       ok(!$c->sessionid, "no session id yet");
-       ok(!$c->user_exists, "no user exists");
-       ok(!$c->user, "no user yet");
-       ok($c->login( "foo", "s3cr3t" ), "can login with clear");
-       is( $c->user, $users->{foo}, "user object is in proper place");
-}
-
-sub elk : Local {
-       my ( $self, $c ) = @_;
-
-       ok( $c->sessionid, "session ID was restored" );
-       ok( $c->user_exists, "user exists" );
-       ok( $c->user, "a user was also restored");
-       is_deeply( $c->user, $users->{foo}, "restored user is the right one (deep test - store might change identity)" );
-       
-       # Rename the user!
-       $users->{bar} = delete $users->{foo};
-}
-
-sub yak : Local {
-    my ( $self, $c ) = @_;
-    ok( $c->sessionid, "session ID was restored after user renamed" );
-    ok( $c->user_exists, "user appears to exist" );
-    ok( !$c->user, "user was not restored");
-    ok(scalar(@{ $c->error }), 'Error recorded');
-    ok( !$c->user_exists, "user no longer appears to exist" );
-}
-
-sub goat : Local {
-    my ( $self, $c ) = @_;
-    ok($c->login( "bar", "s3cr3t" ), "can login with clear (new username)");
-    is( $c->user, $users->{bar}, "user object is in proper place");
-    $c->logout;
-}
-
-sub fluffy_bunny : Local {
-    my ( $self, $c ) = @_;
-
-    ok( $c->session_is_valid, "session ID is restored after logout");
-    ok( !$c->user, "no user was restored after logout");
-       
-    $c->delete_session("bah");
-}
-
-sub possum : Local {
-    my ( $self, $c ) = @_;
-
-       ok( !$c->session_is_valid, "no session ID was restored");
-    $c->session->{definitely_not_a_user} = "moose";
-
-}
-
-sub butterfly : Local {
-    my ( $self, $c ) = @_;
-
-    ok( $c->session_is_valid, "valid session" );
-    ok( !$c->user_exists, "but no user exists" );
-    ok( !$c->user, "no user object either" );
-}
-
-__PACKAGE__->config->{'authentication'}{users} = $users = {
+our $users = {
        foo => User::SessionRestoring->new(
                id => 'foo',
                password => "s3cr3t",
        ),
 };
 
+__PACKAGE__->config(authentication => {users => $users});
+
 __PACKAGE__->setup;
 
 $users->{foo}{store} = __PACKAGE__->default_auth_store;
+
+1;
+
diff --git a/t/lib/AuthSessionTestApp/Controller/Root.pm b/t/lib/AuthSessionTestApp/Controller/Root.pm
new file mode 100644 (file)
index 0000000..2475553
--- /dev/null
@@ -0,0 +1,77 @@
+package AuthSessionTestApp::Controller::Root;
+use strict;
+use warnings;
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config(namespace => '');
+
+use Test::More;
+use Test::Exception;
+
+use Digest::MD5 qw/md5/;
+
+sub moose : Local {
+       my ( $self, $c ) = @_;
+
+       ok(!$c->sessionid, "no session id yet");
+       ok(!$c->user_exists, "no user exists");
+       ok(!$c->user, "no user yet");
+       ok($c->login( "foo", "s3cr3t" ), "can login with clear");
+       is( $c->user, $AuthSessionTestApp::users->{foo}, "user object is in proper place");
+}
+
+sub elk : Local {
+       my ( $self, $c ) = @_;
+
+       ok( $c->sessionid, "session ID was restored" );
+       ok( $c->user_exists, "user exists" );
+       ok( $c->user, "a user was also restored");
+       is_deeply( $c->user, $AuthSessionTestApp::users->{foo}, "restored user is the right one (deep test - store might change identity)" );
+
+       # Rename the user!
+       $AuthSessionTestApp::users->{bar} = delete $AuthSessionTestApp::users->{foo};
+}
+
+sub yak : Local {
+    my ( $self, $c ) = @_;
+    ok( $c->sessionid, "session ID was restored after user renamed" );
+    ok( $c->user_exists, "user appears to exist" );
+    ok( !$c->user, "user was not restored");
+    ok(scalar(@{ $c->error }), 'Error recorded');
+    ok( !$c->user_exists, "user no longer appears to exist" );
+}
+
+sub goat : Local {
+    my ( $self, $c ) = @_;
+    ok($c->login( "bar", "s3cr3t" ), "can login with clear (new username)");
+    is( $c->user, $AuthSessionTestApp::users->{bar}, "user object is in proper place");
+    $c->logout;
+}
+
+sub fluffy_bunny : Local {
+    my ( $self, $c ) = @_;
+
+    ok( $c->session_is_valid, "session ID is restored after logout");
+    ok( !$c->user, "no user was restored after logout");
+
+    $c->delete_session("bah");
+}
+
+sub possum : Local {
+    my ( $self, $c ) = @_;
+
+       ok( !$c->session_is_valid, "no session ID was restored");
+    $c->session->{definitely_not_a_user} = "moose";
+
+}
+
+sub butterfly : Local {
+    my ( $self, $c ) = @_;
+
+    ok( $c->session_is_valid, "valid session" );
+    ok( !$c->user_exists, "but no user exists" );
+    ok( !$c->user, "no user object either" );
+}
+
+1;
+
index 529e32f..c7c49df 100644 (file)
@@ -1,81 +1,41 @@
 package AuthTestApp;
+use strict;
+use warnings;
+use base qw/Catalyst/;
 use Catalyst qw/
        Authentication
        Authentication::Store::Minimal
        Authentication::Credential::Password
 /;
 
-use Test::More;
-use Test::Exception;
-
 use Digest::MD5 qw/md5/;
 use Digest::SHA1 qw/sha1_base64/;
 
-our $users;
-
-sub number_of_elements { return scalar @_ }
-
-sub moose : Local {
-       my ( $self, $c ) = @_;
-
-       is(number_of_elements($c->user), 1, "Array undef");
-       is($c->user, undef, "no user, returns undef");
-       ok(!$c->user, "no user");
-       ok($c->login( "foo", "s3cr3t" ), "can login with clear");
-       is( $c->user, $users->{foo}, "user object is in proper place");
-
-       ok( !$c->user->roles, "no roles for foo" );
-       my @new = qw/foo bar gorch/;
-       $c->user->roles( @new );
-       is_deeply( [ $c->user->roles ], \@new, "roles set as array");
-
-       $c->logout;
-       ok(!$c->user, "no more user, after logout");
-
-       ok($c->login( "bar", "s3cr3t" ), "can login with crypted");
-       is( $c->user, $users->{bar}, "user object is in proper place");
-       $c->logout;
-
-       ok($c->login("gorch", "s3cr3t"), "can login with hashed");
-       is( $c->user, $users->{gorch}, "user object is in proper place");
-       $c->logout;
-
-       ok($c->login("shabaz", "s3cr3t"), "can login with base64 hashed");
-       is( $c->user, $users->{shabaz}, "user object is in proper place");
-       $c->logout;
-
-       ok($c->login("sadeek", "s3cr3t"), "can login with padded base64 hashed");
-       is( $c->user, $users->{sadeek}, "user object is in proper place");
-       $c->logout;
-
-       ok(!$c->login( "bar", "bad pass" ), "can't login with bad password");
-       ok(!$c->user, "no user");
+our $users = {
+    foo => {
+        password => "s3cr3t",
+    },
+    bar => {
+        crypted_password => crypt("s3cr3t", "x8"),
+    },
+    gorch => {
+        hashed_password => md5("s3cr3t"),
+        hash_algorithm => "MD5",
+    },
+    shabaz => {
+        hashed_password => sha1_base64("s3cr3t"),
+        hash_algorithm => "SHA-1"
+    },
+    sadeek => {
+        hashed_password => sha1_base64("s3cr3t").'=',
+        hash_algorithm => "SHA-1"
+    },
+    baz => {},
+};
 
-       throws_ok { $c->login( "baz", "foo" ) } qr/support.*mechanism/, "can't login without any supported mech";
+__PACKAGE__->config('Plugin::Authentication' =>{users => $users});
 
-       $c->res->body( "ok" );
-}
+__PACKAGE__->setup;
 
-__PACKAGE__->config->{'Plugin::Authentication'}{users} = $users = {
-       foo => {
-               password => "s3cr3t",
-       },
-       bar => {
-               crypted_password => crypt("s3cr3t", "x8"),
-       },
-       gorch => {
-               hashed_password => md5("s3cr3t"),
-               hash_algorithm => "MD5",
-       },
-       shabaz => {
-               hashed_password => sha1_base64("s3cr3t"),
-               hash_algorithm => "SHA-1"
-       },
-       sadeek => {
-               hashed_password => sha1_base64("s3cr3t").'=',
-               hash_algorithm => "SHA-1"
-       },
-       baz => {},
-};
+1;
 
-__PACKAGE__->setup;
diff --git a/t/lib/AuthTestApp/Controller/Root.pm b/t/lib/AuthTestApp/Controller/Root.pm
new file mode 100644 (file)
index 0000000..c2751fa
--- /dev/null
@@ -0,0 +1,57 @@
+package AuthTestApp::Controller::Root;
+use strict;
+use warnings;
+use base qw/ Catalyst::Controller /;
+
+__PACKAGE__->config( namespace => '' );
+
+use Test::More;
+use Test::Exception;
+
+use Digest::MD5 qw/md5/;
+use Digest::SHA1 qw/sha1_base64/;
+
+sub number_of_elements { return scalar @_ }
+
+sub moose : Local {
+       my ( $self, $c ) = @_;
+
+       is(number_of_elements($c->user), 1, "Array undef");
+       is($c->user, undef, "no user, returns undef");
+       ok(!$c->user, "no user");
+       ok($c->login( "foo", "s3cr3t" ), "can login with clear");
+       is( $c->user, $AuthTestApp::users->{foo}, "user object is in proper place");
+
+       ok( !$c->user->roles, "no roles for foo" );
+       my @new = qw/foo bar gorch/;
+       $c->user->roles( @new );
+       is_deeply( [ $c->user->roles ], \@new, "roles set as array");
+
+       $c->logout;
+       ok(!$c->user, "no more user, after logout");
+
+       ok($c->login( "bar", "s3cr3t" ), "can login with crypted");
+       is( $c->user, $AuthTestApp::users->{bar}, "user object is in proper place");
+       $c->logout;
+
+       ok($c->login("gorch", "s3cr3t"), "can login with hashed");
+       is( $c->user, $AuthTestApp::users->{gorch}, "user object is in proper place");
+       $c->logout;
+
+       ok($c->login("shabaz", "s3cr3t"), "can login with base64 hashed");
+       is( $c->user, $AuthTestApp::users->{shabaz}, "user object is in proper place");
+       $c->logout;
+
+       ok($c->login("sadeek", "s3cr3t"), "can login with padded base64 hashed");
+       is( $c->user, $AuthTestApp::users->{sadeek}, "user object is in proper place");
+       $c->logout;
+
+       ok(!$c->login( "bar", "bad pass" ), "can't login with bad password");
+       ok(!$c->user, "no user");
+
+       throws_ok { $c->login( "baz", "foo" ) } qr/support.*mechanism/, "can't login without any supported mech";
+
+       $c->res->body( "ok" );
+}
+
+
index dbba67c..669cf10 100644 (file)
@@ -1,5 +1,6 @@
 package RemoteTestApp1;
-
+use strict;
+use warnings;
 use Catalyst qw/
    Authentication
 /;
@@ -25,21 +26,7 @@ __PACKAGE__->config(
     },
 );
 
-sub default : Local {
-    my ( $self, $c ) = @_;
-    if ($c->authenticate()) {
-        $c->res->body('User:' . $c->user->{username});
-    }
-    else {
-        $c->res->body('FAIL');
-        $c->res->status(403);
-    }
-}
-
-sub public : Local {
-    my ( $self, $c ) = @_;
-    $c->res->body('OK');
-}
-
 __PACKAGE__->setup;
 
+1;
+
diff --git a/t/lib/RemoteTestApp1/Controller/Root.pm b/t/lib/RemoteTestApp1/Controller/Root.pm
new file mode 100644 (file)
index 0000000..a3c1310
--- /dev/null
@@ -0,0 +1,25 @@
+package RemoteTestApp1::Controller::Root;
+use strict;
+use warnings;
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config(namespace => '');
+
+sub default : Local {
+    my ( $self, $c ) = @_;
+    if ($c->authenticate()) {
+        $c->res->body('User:' . $c->user->{username});
+    }
+    else {
+        $c->res->body('FAIL');
+        $c->res->status(403);
+    }
+}
+
+sub public : Local {
+    my ( $self, $c ) = @_;
+    $c->res->body('OK');
+}
+
+1;
+
index 6aa2675..159020f 100644 (file)
@@ -1,4 +1,6 @@
 package RemoteTestApp2;
+use strict;
+use warnings;
 
 use Catalyst qw/
    Authentication
@@ -27,24 +29,7 @@ __PACKAGE__->config(
     },
 );
 
-sub default : Local {
-    my ( $self, $c ) = @_;
-    if ($c->authenticate()) {
-        $c->res->body( 
-              'my_user_name:'
-              . $c->user->{my_user_name}
-        );
-    }
-    else {
-        $c->res->body('FAIL');
-        $c->res->status(403);
-    }
-}
-
-sub public : Local {
-    my ( $self, $c ) = @_;
-    $c->res->body('OK');
-}
-
 __PACKAGE__->setup;
 
+1;
+
diff --git a/t/lib/RemoteTestApp2/Controller/Root.pm b/t/lib/RemoteTestApp2/Controller/Root.pm
new file mode 100644 (file)
index 0000000..dfbcd46
--- /dev/null
@@ -0,0 +1,28 @@
+package RemoteTestApp2::Controller::Root;
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config(namespace => '');
+
+sub default : Local {
+    my ( $self, $c ) = @_;
+    if ($c->authenticate()) {
+        $c->res->body(
+              'my_user_name:'
+              . $c->user->{my_user_name}
+        );
+    }
+    else {
+        $c->res->body('FAIL');
+        $c->res->status(403);
+    }
+}
+
+sub public : Local {
+    my ( $self, $c ) = @_;
+    $c->res->body('OK');
+}
+
+1;
+
index 70ca676..4d55cd5 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More; 
+use Test::More;
 
 BEGIN {
     plan skip_all => "Digest::SHA1 is required for this test" unless eval { require Digest::SHA1 };
index bf5fe6b..f7131e5 100644 (file)
@@ -1,9 +1,12 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More;
 
 use lib 't/lib';
 use Catalyst::Test qw/AuthRealmTestAppProgressive/;
 
 ok(get("/progressive"), "get ok");
+
+done_testing;
+
index 2d43550..7169b46 100644 (file)
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use Test::More tests => 10;
+use Test::More;
 
 use lib 't/lib';
 use Catalyst::Test qw/RemoteTestApp1/;
@@ -28,3 +28,6 @@ is( request('/')->content, 'User:namexyz', 'testing "cutname" option 2' );
 
 $RemoteTestEngine::REMOTE_USER = 'CN=/OU=Test/C=Company';
 is( request('/')->content, 'User:CN=/OU=Test/C=Company', 'testing "cutname" option - empty $1 match' );
+
+done_testing;
+
index f59f4b4..6b01320 100644 (file)
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use Test::More tests => 3;
+use Test::More;
 
 use lib 't/lib';
 use Catalyst::Test qw/RemoteTestApp2/;
@@ -18,3 +18,6 @@ $RemoteTestEngine::SSL_CLIENT_S_DN = 'CN=namexyz/OU=Test/C=Company';
 ok( request('/')->is_success, 'testing "source" + "cutname" 1' );
 is( request('/')->content, "my_user_name:namexyz",
    'testing "source" + "cutname" 2' );
+
+done_testing;
+
index 65793eb..ac99352 100644 (file)
@@ -8,7 +8,6 @@ BEGIN {
        plan skip_all => "This test needs Test::WWW::Mechanize::Catalyst, Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed" if $@;
     plan skip_all => "This test needs Test::WWW::Mechanize::Catalyst >= 0.50, you have only $Test::WWW::Mechanize::Catalyst::VERSION"
         unless $Test::WWW::Mechanize::Catalyst::VERSION >= 0.50;
-    plan tests => 29;
 }
 
 use lib 't/lib';
@@ -22,8 +21,9 @@ $m->get_ok("http://localhost/elk", "get ok");
 $m->get("http://localhost/yak");
 ok(!$m->success, 'Not ok, user unable to be resotred == nasal demons');
 
-$m->get_ok("http://localhost/goat", "get ok");
-$m->get_ok("http://localhost/fluffy_bunny", "get ok");
-$m->get_ok("http://localhost/possum", "get ok");
-$m->get_ok("http://localhost/butterfly", "get ok");
+foreach my $type (qw/ goat fluffy_bunny possum butterfly /) {
+    $m->get_ok("http://localhost/$type", "get $type ok");
+}
+
+done_testing;