[Catalyst-commits] r11541 - in
Catalyst-Plugin-Authentication/0.10000/trunk: . t t/lib
t/lib/AuthRealmTestApp t/lib/AuthRealmTestApp/Controller
t/lib/AuthRealmTestAppCompat t/lib/AuthRealmTestAppCompat/Controller
t/lib/AuthRealmTestAppProgressive
t/lib/AuthRealmTestAppProgressive/Controller
t/lib/AuthSessionTestApp t/lib/AuthSessionTestApp/Controller
t/lib/AuthTestApp t/lib/AuthTestApp/Controller
t/lib/RemoteTestApp1 t/lib/RemoteTestApp1/Controller
t/lib/RemoteTestApp2 t/lib/RemoteTestApp2/Controller
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Fri Oct 16 01:28:17 GMT 2009
Author: t0m
Date: 2009-10-16 01:28:16 +0000 (Fri, 16 Oct 2009)
New Revision: 11541
Added:
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp/Controller/Root.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat/Controller/Root.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp/Controller/Root.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp/Controller/Root.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1/Controller/Root.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2/Controller/
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2/Controller/Root.pm
Modified:
Catalyst-Plugin-Authentication/0.10000/trunk/Changes
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app.t
Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_realms_progressive.t
Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote1.t
Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t
Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_session.t
Log:
Epic cleanup and code shuffle in tests to avoid warnings
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/Changes
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/Changes 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/Changes 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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)
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestApp.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -25,69 +25,7 @@
}
};
-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 @@
},
store => {
class => 'Minimal',
- users => $members
+ users => $members
}
},
admins => {
@@ -109,10 +47,13 @@
},
store => {
class => 'Minimal',
- users => $admins
+ users => $admins
}
}
}
-};
+});
__PACKAGE__->setup;
+
+1;
+
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppCompat.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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 @@
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 @@
users => $members,
}
},
-
-};
+});
__PACKAGE__->setup;
+
+1;
+
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthRealmTestAppProgressive.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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 @@
Authentication::Store::Minimal
/;
-use Test::More;
-use Test::Exception;
-
our %members = (
'members' => {
bob => { password => "s00p3r" }
@@ -25,7 +23,7 @@
},
);
-__PACKAGE__->config->{'Plugin::Authentication'} = {
+__PACKAGE__->config('Plugin::Authentication' => {
default_realm => 'progressive',
progressive => {
class => 'Progressive',
@@ -53,25 +51,9 @@
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;
+
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthSessionTestApp.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -5,6 +5,10 @@
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 @@
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;
+
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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" );
+}
+
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/AuthTestApp.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+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 => {},
+};
-sub number_of_elements { return scalar @_ }
+__PACKAGE__->config('Plugin::Authentication' =>{users => $users});
-sub moose : Local {
- my ( $self, $c ) = @_;
+__PACKAGE__->setup;
- 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");
+1;
- 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");
-
- throws_ok { $c->login( "baz", "foo" ) } qr/support.*mechanism/, "can't login without any supported mech";
-
- $c->res->body( "ok" );
-}
-
-__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 => {},
-};
-
-__PACKAGE__->setup;
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp1.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -1,5 +1,6 @@
package RemoteTestApp1;
-
+use strict;
+use warnings;
use Catalyst qw/
Authentication
/;
@@ -25,21 +26,7 @@
},
);
-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;
+
Added: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2/Controller/Root.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm 2009-10-16 01:28:16 UTC (rev 11541)
@@ -1,4 +1,6 @@
package RemoteTestApp2;
+use strict;
+use warnings;
use Catalyst qw/
Authentication
@@ -27,24 +29,7 @@
},
);
-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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app.t
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app.t 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app.t 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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 };
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_realms_progressive.t
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_realms_progressive.t 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_realms_progressive.t 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote1.t
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote1.t 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote1.t 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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 @@
$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;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t 2009-10-16 01:28:16 UTC (rev 11541)
@@ -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 @@
ok( request('/')->is_success, 'testing "source" + "cutname" 1' );
is( request('/')->content, "my_user_name:namexyz",
'testing "source" + "cutname" 2' );
+
+done_testing;
+
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_session.t
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_session.t 2009-10-16 00:50:28 UTC (rev 11540)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_session.t 2009-10-16 01:28:16 UTC (rev 11541)
@@ -8,7 +8,6 @@
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("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;
+
More information about the Catalyst-commits
mailing list