[Catalyst-commits] r11748 - in Catalyst-Plugin-Session/0.00/trunk:
. lib/Catalyst/Plugin t t/lib t/lib/SessionValid
t/lib/SessionValid/Controller
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Nov 4 22:45:02 GMT 2009
Author: t0m
Date: 2009-11-04 22:45:01 +0000 (Wed, 04 Nov 2009)
New Revision: 11748
Added:
Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid.pm
Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid/
Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid/Controller/
Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid/Controller/Root.pm
Catalyst-Plugin-Session/0.00/trunk/t/session_valid.t
Modified:
Catalyst-Plugin-Session/0.00/trunk/
Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm
Log:
r11775 at t0mlaptop (orig r11740): jsut | 2009-11-04 19:36:52 +0000
Branch to commit failing tests
r11777 at t0mlaptop (orig r11742): jsut | 2009-11-04 19:53:19 +0000
Added a failing test for a situation that occurs when you have a cookie for a session that's expired. If you subsequently call 'session_is_valid' in the same request, the newly created session is deleted for being expired, despite the fact it was just created.
r11779 at t0mlaptop (orig r11744): jsut | 2009-11-04 21:38:49 +0000
This patch makes it so that the expiry is not looked up in the underlying store when a session has not yet committed to the store.
Probably not the most graceful way to do it, but it works.
Property changes on: Catalyst-Plugin-Session/0.00/trunk
___________________________________________________________________
Name: svk:merge
- 4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Plugin-Session/0.00/branches/accessor_change:11675
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Plugin-Session:10129
+ 4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Plugin-Session/0.00/branches/accessor_change:11675
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Plugin-Session/0.00/branches/session_deleted_bug:11744
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Plugin-Session:10129
Modified: Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm 2009-11-04 22:42:04 UTC (rev 11747)
+++ Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm 2009-11-04 22:45:01 UTC (rev 11748)
@@ -375,6 +375,11 @@
my $exp = $c->calculate_initial_session_expires;
$c->_session_expires( $exp );
+ #
+ # since we're setting _session_expires directly, make load_session_expires
+ # actually use that value.
+ #
+ $c->_tried_loading_session_expires(1);
$c->_extended_session_expires( $exp );
$exp;
}
Added: Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid/Controller/Root.pm (rev 0)
+++ Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid/Controller/Root.pm 2009-11-04 22:45:01 UTC (rev 11748)
@@ -0,0 +1,17 @@
+package SessionValid::Controller::Root;
+use strict;
+use warnings;
+use Data::Dumper;
+
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config( namespace => '' );
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+ $c->session->{'value'} = 'value set';
+ $c->session_is_valid;
+ $c->res->output($c->session->{'value'});
+}
+
+1;
Added: Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid.pm
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid.pm (rev 0)
+++ Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionValid.pm 2009-11-04 22:45:01 UTC (rev 11748)
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+
+package SessionValid;
+use Catalyst qw/Session Session::Store::Dummy Session::State::Cookie/;
+
+use strict;
+use warnings;
+
+__PACKAGE__->config->{'session'} = {
+ cookie_expires => 0,
+ expires => 1,
+};
+
+__PACKAGE__->setup;
+
+__PACKAGE__;
+
Added: Catalyst-Plugin-Session/0.00/trunk/t/session_valid.t
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/t/session_valid.t (rev 0)
+++ Catalyst-Plugin-Session/0.00/trunk/t/session_valid.t 2009-11-04 22:45:01 UTC (rev 11748)
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+BEGIN {
+ eval { require Catalyst::Plugin::Session::State::Cookie; Catalyst::Plugin::Session::State::Cookie->VERSION(0.03) }
+ or plan skip_all =>
+ "Catalyst::Plugin::Session::State::Cookie 0.03 or higher is required for this test";
+
+ eval {
+ require Test::WWW::Mechanize::Catalyst;
+ Test::WWW::Mechanize::Catalyst->VERSION(0.51);
+ }
+ or plan skip_all =>
+ 'Test::WWW::Mechanize::Catalyst >= 0.51 is required for this test';
+
+ plan tests => 4;
+}
+
+use lib "t/lib";
+use Test::WWW::Mechanize::Catalyst "SessionValid";
+
+my $ua = Test::WWW::Mechanize::Catalyst->new;
+
+$ua->get_ok( "http://localhost/", "initial get" );
+$ua->content_contains( "value set", "page contains expected value" );
+
+sleep 2;
+
+$ua->get_ok( "http://localhost/", "grab the page again, after the session has expired" );
+$ua->content_contains( "value set", "page contains expected value" );
+
More information about the Catalyst-commits
mailing list