From: Devin Austin Date: Fri, 30 Mar 2012 20:32:41 +0000 (-0700) Subject: tests pass for address change test per https://rt.cpan.org/Public/Bug/Display.html... X-Git-Tag: v0.32^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83a3f0e991b5fc11342ac80ba8e7653f938dd795;p=catagits%2FCatalyst-Plugin-Session.git tests pass for address change test per https://rt.cpan.org/Public/Bug/Display.html?id=71142#txn-1001261 --- diff --git a/Makefile.PL b/Makefile.PL index 69bbbbf..4646723 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -30,7 +30,8 @@ requires 'Test::More' => '0.88'; test_requires 'Test::Deep'; test_requires 'Test::Exception'; - +test_requires 'Test::WWW::Mechanize::PSGI'; +test_requires 'Plack::Middleware::ForceEnv'; resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Plugin-Session/0.00/trunk/'; WriteAll; diff --git a/t/live_verify_address.t b/t/live_verify_address.t index 7b04db6..3b2ca71 100644 --- a/t/live_verify_address.t +++ b/t/live_verify_address.t @@ -4,29 +4,32 @@ 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); + require Test::WWW::Mechanize::PSGI; + #Test::WWW::Mechanize::Catalyst->VERSION(0.51); } or plan skip_all => - 'Test::WWW::Mechanize::Catalyst >= 0.51 is required for this test'; + 'Test::WWW::Mechanize::PSGI is required for this test'; plan tests => 12; } use lib "t/lib"; -use Test::WWW::Mechanize::Catalyst "SessionTestApp"; +use Test::WWW::Mechanize::PSGI; +use SessionTestApp; +my $ua = Test::WWW::Mechanize::PSGI->new( + app => SessionTestApp->psgi_app(@_), + cookie_jar => {} +); # 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'); @@ -35,10 +38,19 @@ $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.'); +#local $ENV{REMOTE_ADDR} = "192.168.1.2"; +use Plack::Builder; +my $app = SessionTestApp->psgi_app(@_); +builder { + enable 'ForceEnv' => REMOTE_ADDR => "192.168.1.2"; + $app; +}; +my $ua2 = Test::WWW::Mechanize::PSGI->new( + app => $app, + cookie_jar => {} +); +$ua2->get_ok( "http://localhost/get_session_variable/logged"); +$ua2->content_contains('VAR_logged=n.a.'); # Inital Client local $ENV{REMOTE_ADDR} = "192.168.1.1";