[Catalyst-commits] r6511 - in
branches/Catalyst-Plugin-Authentication: lib/Catalyst/Plugin
lib/Catalyst/Plugin/Authentication t t/lib
jayk at dev.catalyst.perl.org
jayk at dev.catalyst.perl.org
Sat Jul 7 03:05:09 GMT 2007
Author: jayk
Date: 2007-07-07 03:05:09 +0100 (Sat, 07 Jul 2007)
New Revision: 6511
Added:
branches/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm
Removed:
branches/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm
Modified:
branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm
branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm
Log:
Moving AuthRealmTestApp.pm to proper directory
Correcting backwards compatibility bug with $user->store()
thanks to nilsonsfj for finding this bug
Modified: branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm
===================================================================
--- branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm 2007-07-06 23:43:08 UTC (rev 6510)
+++ branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/User.pm 2007-07-07 02:05:09 UTC (rev 6511)
@@ -8,7 +8,7 @@
## auth_realm is the realm this user came from.
BEGIN {
- __PACKAGE__->mk_accessors(qw/auth_realm/);
+ __PACKAGE__->mk_accessors(qw/auth_realm store/);
}
## THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only.
@@ -68,10 +68,11 @@
## Backwards Compatibility
## you probably want auth_realm, in fact. but this does work for backwards compatibility.
-sub store {
- my ($self) = @_;
- return $self->auth_realm->{store};
-}
+## store should be a read-write accessor - so it was moved to mk_accessors
+##sub store {
+## my ($self) = @_;
+## return $self->auth_realm->{store};
+##}
__PACKAGE__;
Modified: branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm
===================================================================
--- branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm 2007-07-06 23:43:08 UTC (rev 6510)
+++ branches/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm 2007-07-07 02:05:09 UTC (rev 6511)
@@ -40,6 +40,7 @@
$c->save_user_in_session($user, $realmname);
}
$user->auth_realm($realmname);
+ $user->store(ref($c->auth_realms->{$realmname}{'store'}));
$c->NEXT::set_authenticated($user, $realmname);
}
@@ -149,6 +150,10 @@
# this sets the realm the user originated in.
$user->auth_realm($realmname);
+ ## compatibility - some pre 0.10 store / credentials may need the store name,
+ ## this is not used by the current api in any form.
+ $user->store(ref($c->auth_realms->{$realmname}{'store'}));
+
return $user;
}
Deleted: branches/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm
===================================================================
--- branches/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm 2007-07-06 23:43:08 UTC (rev 6510)
+++ branches/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm 2007-07-07 02:05:09 UTC (rev 6511)
@@ -1,115 +0,0 @@
-package AuthRealmTestApp;
-use warnings;
-use strict;
-
-use Catalyst qw/Authentication/;
-
-use Test::More;
-use Test::Exception;
-
-our $members = {
- bob => {
- password => "s00p3r"
- },
- william => {
- password => "s3cr3t"
- }
-};
-
-our $admins = {
- joe => {
- password => "31337"
- }
-};
-
-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->{authentication} = {
- default_realm => 'members',
- realms => {
- members => {
- credential => {
- class => 'Password',
- password_field => 'password',
- password_type => 'clear'
- },
- store => {
- class => 'Minimal',
- users => $members
- }
- },
- admins => {
- credential => {
- class => 'Password',
- password_field => 'password',
- password_type => 'clear'
- },
- store => {
- class => 'Minimal',
- users => $admins
- }
- }
- }
-};
-
-__PACKAGE__->setup;
Copied: branches/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm (from rev 6509, branches/Catalyst-Plugin-Authentication/t/AuthRealmTestApp.pm)
===================================================================
--- branches/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm (rev 0)
+++ branches/Catalyst-Plugin-Authentication/t/lib/AuthRealmTestApp.pm 2007-07-07 02:05:09 UTC (rev 6511)
@@ -0,0 +1,115 @@
+package AuthRealmTestApp;
+use warnings;
+use strict;
+
+use Catalyst qw/Authentication/;
+
+use Test::More;
+use Test::Exception;
+
+our $members = {
+ bob => {
+ password => "s00p3r"
+ },
+ william => {
+ password => "s3cr3t"
+ }
+};
+
+our $admins = {
+ joe => {
+ password => "31337"
+ }
+};
+
+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->{authentication} = {
+ default_realm => 'members',
+ realms => {
+ members => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'clear'
+ },
+ store => {
+ class => 'Minimal',
+ users => $members
+ }
+ },
+ admins => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'clear'
+ },
+ store => {
+ class => 'Minimal',
+ users => $admins
+ }
+ }
+ }
+};
+
+__PACKAGE__->setup;
More information about the Catalyst-commits
mailing list