[Catalyst-commits] r14033 - in Catalyst-Plugin-Session/0.00/trunk:
lib/Catalyst/Plugin t t/lib t/lib/SessionTestApp/Controller
jegade at dev.catalyst.perl.org
jegade at dev.catalyst.perl.org
Wed Jun 8 11:43:18 GMT 2011
Author: jegade
Date: 2011-06-08 11:43:18 +0000 (Wed, 08 Jun 2011)
New Revision: 14033
Added:
Catalyst-Plugin-Session/0.00/trunk/t/live_verify_address.t
Modified:
Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm
Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp.pm
Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp/Controller/Root.pm
Log:
Test for verify address and fix reset __address
Modified: Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm 2011-06-06 14:46:06 UTC (rev 14032)
+++ Catalyst-Plugin-Session/0.00/trunk/lib/Catalyst/Plugin/Session.pm 2011-06-08 11:43:18 UTC (rev 14033)
@@ -225,6 +225,7 @@
no warnings 'uninitialized'; # ne __address
if ( $c->_session_plugin_config->{verify_address}
+ && exists $session_data->{__address}
&& $session_data->{__address} ne $c->request->address )
{
$c->log->warn(
Modified: Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp/Controller/Root.pm
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp/Controller/Root.pm 2011-06-06 14:46:06 UTC (rev 14032)
+++ Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp/Controller/Root.pm 2011-06-08 11:43:18 UTC (rev 14033)
@@ -13,6 +13,14 @@
$c->res->output("logged in");
}
+sub login_without_address : Global {
+ my ( $self, $c ) = @_;
+ $c->session;
+ $c->log->debug($c->request->address);
+ delete $c->session->{__address};
+ $c->res->output("logged in (without address)");
+}
+
sub logout : Global {
my ( $self, $c ) = @_;
$c->res->output(
Modified: Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp.pm
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp.pm 2011-06-06 14:46:06 UTC (rev 14032)
+++ Catalyst-Plugin-Session/0.00/trunk/t/lib/SessionTestApp.pm 2011-06-08 11:43:18 UTC (rev 14033)
@@ -9,6 +9,10 @@
__PACKAGE__->config('Plugin::Session' => {
# needed for live_verify_user_agent.t; should be harmless for other tests
verify_user_agent => 1,
+
+ # need for live_verify_address.t; should be harmless for other tests
+ verify_address => 1,
+
});
__PACKAGE__->setup;
Added: Catalyst-Plugin-Session/0.00/trunk/t/live_verify_address.t
===================================================================
--- Catalyst-Plugin-Session/0.00/trunk/t/live_verify_address.t (rev 0)
+++ Catalyst-Plugin-Session/0.00/trunk/t/live_verify_address.t 2011-06-08 11:43:18 UTC (rev 14033)
@@ -0,0 +1,59 @@
+#!/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 => 12;
+}
+
+use lib "t/lib";
+use Test::WWW::Mechanize::Catalyst "SessionTestApp";
+
+# Test without delete __address
+local $ENV{REMOTE_ADDR} = "192.168.1.1";
+
+my $ua = Test::WWW::Mechanize::Catalyst->new( {} );
+$ua->get_ok( "http://localhost/login" );
+$ua->content_contains('logged in');
+
+$ua->get_ok( "http://localhost/set_session_variable/logged/in" );
+$ua->content_contains('session variable set');
+
+
+# Change Client
+local $ENV{REMOTE_ADDR} = "192.168.1.2";
+
+$ua->get_ok( "http://localhost/get_session_variable/logged");
+$ua->content_contains('VAR_logged=n.a.');
+
+# Inital Client
+local $ENV{REMOTE_ADDR} = "192.168.1.1";
+
+$ua->get_ok( "http://localhost/login_without_address" );
+$ua->content_contains('logged in (without address)');
+
+$ua->get_ok( "http://localhost/set_session_variable/logged/in" );
+$ua->content_contains('session variable set');
+
+# Change Client
+local $ENV{REMOTE_ADDR} = "192.168.1.2";
+
+$ua->get_ok( "http://localhost/get_session_variable/logged" );
+$ua->content_contains('VAR_logged=in');
+
+
+
More information about the Catalyst-commits
mailing list