[Catalyst-commits] r13694 - in
Catalyst-Authentication-Store-DBIx-Class/trunk: .
lib/Catalyst/Authentication/Store/DBIx/Class t t/lib
t/lib/Catalyst t/lib/Catalyst/Authentication
t/lib/Catalyst/Authentication/Store
t/lib/Catalyst/Authentication/Store/Person
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Nov 17 18:56:52 GMT 2010
Author: t0m
Date: 2010-11-17 18:56:52 +0000 (Wed, 17 Nov 2010)
New Revision: 13694
Added:
Catalyst-Authentication-Store-DBIx-Class/trunk/t/11-authsessions-load-app-context.t
Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/
Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/
Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/
Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person.pm
Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person/
Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person/User.pm
Modified:
Catalyst-Authentication-Store-DBIx-Class/trunk/
Catalyst-Authentication-Store-DBIx-Class/trunk/Changes
Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
Log:
Fix bug, patch from Anthony Gladdish on mailing list
Property changes on: Catalyst-Authentication-Store-DBIx-Class/trunk
___________________________________________________________________
Added: svn:ignore
+ META.yml
README
pm_to_blib
MANIFEST
Catalyst-Authentication-Store-DBIx-Class-*.tar.gz
blib
inc
Makefile
Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/Changes
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/Changes 2010-11-15 18:46:05 UTC (rev 13693)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/Changes 2010-11-17 18:56:52 UTC (rev 13694)
@@ -1,5 +1,8 @@
Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class
+0.1401 2010-11-16
+ * Fix call to ->load which was not passing $c
+
0.1400 2010-09-01
* Make can() work as well as AUTOLOADing.
Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm 2010-11-15 18:46:05 UTC (rev 13693)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm 2010-11-17 18:56:52 UTC (rev 13694)
@@ -190,7 +190,7 @@
return $self->load({
map { ($_ => $frozenuser->{$_}) }
@{ $self->config->{id_field} }
- });
+ }, $c);
}
return $self->load( { $self->config->{'id_field'} => $frozenuser }, $c);
Added: Catalyst-Authentication-Store-DBIx-Class/trunk/t/11-authsessions-load-app-context.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/11-authsessions-load-app-context.t (rev 0)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/11-authsessions-load-app-context.t 2010-11-17 18:56:52 UTC (rev 13694)
@@ -0,0 +1,79 @@
+#!perl
+
+use strict;
+use warnings;
+use DBI;
+use File::Path;
+use FindBin;
+use Test::More;
+use lib "$FindBin::Bin/lib";
+
+BEGIN {
+ eval { require Test::WWW::Mechanize::Catalyst }
+ or plan skip_all =>
+ "Test::WWW::Mechanize::Catalyst is required for this test";
+
+ eval { require DBD::SQLite }
+ or plan skip_all =>
+ "DBD::SQLite is required for this test";
+
+ eval { require DBIx::Class }
+ or plan skip_all =>
+ "DBIx::Class is required for this test";
+
+ eval { require Catalyst::Plugin::Session;
+ die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
+ or plan skip_all =>
+ "Catalyst::Plugin::Session >= 0.02 is required for this test";
+
+ eval { require Catalyst::Plugin::Session::State::Cookie; }
+ or plan skip_all =>
+ "Catalyst::Plugin::Session::State::Cookie is required for this test";
+
+
+ plan tests => 4;
+
+ $ENV{TESTAPP_CONFIG} = {
+ name => 'TestApp',
+ authentication => {
+ default_realm => "users",
+ realms => {
+ users => {
+ credential => {
+ 'class' => 'Password',
+ 'password_field' => 'password',
+ },
+ store => {
+ 'class' => 'Person',
+ 'use_userdata_from_session' => 0,
+ },
+ },
+ },
+ },
+ };
+
+ $ENV{TESTAPP_PLUGINS} = [
+ qw/Authentication
+ Session
+ Session::Store::Dummy
+ Session::State::Cookie
+ /
+ ];
+}
+
+use Test::WWW::Mechanize::Catalyst 'TestApp';
+my $m = Test::WWW::Mechanize::Catalyst->new;
+
+# log a user in
+{
+ $m->get_ok( 'http://localhost/user_login?username=joeuser&password=hackme', undef, 'request ok' );
+ $m->content_is( 'joeuser logged in', 'user logged in ok' );
+}
+
+# verify the user is still logged in
+{
+ $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
+ $m->content_is( 'joeuser', 'user still logged in' );
+}
+
+
Added: Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person/User.pm
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person/User.pm (rev 0)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person/User.pm 2010-11-17 18:56:52 UTC (rev 13694)
@@ -0,0 +1,25 @@
+package Catalyst::Authentication::Store::Person::User;
+
+use strict;
+use warnings;
+use base qw/Catalyst::Authentication::Store::DBIx::Class::User/;
+use base qw/Class::Accessor::Fast/;
+use Data::Dump;
+
+sub load {
+ my ($self, $authinfo, $c) = @_;
+ if ( exists( $authinfo->{'id'} ) ) {
+ $self->_user( $c->model('TestApp::User')->find($authinfo->{'id'}) );
+ } elsif ( exists( $authinfo->{'username'} ) ) {
+ my $u = $c->model('TestApp::User')->find({ username => $authinfo->{'username'} });
+ $self->_user( $u );
+ }
+ if ($self->get_object) {
+ return $self;
+ } else {
+ return undef;
+ }
+}
+
+1;
+__END__
\ No newline at end of file
Added: Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person.pm
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person.pm (rev 0)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/Catalyst/Authentication/Store/Person.pm 2010-11-17 18:56:52 UTC (rev 13694)
@@ -0,0 +1,21 @@
+package Catalyst::Authentication::Store::Person;
+
+use strict;
+use warnings;
+use base qw/Catalyst::Authentication::Store::DBIx::Class/;
+
+our $VERSION= "0.01";
+
+sub new {
+ my ( $class, $config, $app ) = @_;
+ $config->{user_class} = 'TestApp::User';
+ $config->{store_user_class} = 'Catalyst::Authentication::Store::Person::User';
+ $config->{role_relation} = 'role';
+ $config->{role_field} = 'role';
+
+ return $class->SUPER::new( $config, $app );
+}
+
+__PACKAGE__;
+
+__END__
\ No newline at end of file
More information about the Catalyst-commits
mailing list