fix Makefile.PL when no . in @INC
[catagits/Catalyst-Plugin-Session.git] / t / live_verify_address.t
index 7b04db6..e18ca91 100644 (file)
@@ -4,29 +4,35 @@ 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';
+
+    eval { require Catalyst::Plugin::Authentication; 1 }
+      or plan skip_all => "Catalyst::Plugin::Authentication 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');
 
@@ -34,11 +40,15 @@ $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.');
+# Change Client
+use Plack::Builder;
+my $app = SessionTestApp->psgi_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";
@@ -49,7 +59,7 @@ $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 
+# Change Client
 local $ENV{REMOTE_ADDR} = "192.168.1.2";
 
 $ua->get_ok( "http://localhost/get_session_variable/logged" );