fix Makefile.PL when no . in @INC
[catagits/Catalyst-Plugin-Session.git] / t / live_verify_address.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 BEGIN {
8     eval { require Catalyst::Plugin::Session::State::Cookie; Catalyst::Plugin::Session::State::Cookie->VERSION(0.03) }
9       or plan skip_all =>
10       "Catalyst::Plugin::Session::State::Cookie 0.03 or higher is required for this test";
11
12     eval {
13         require Test::WWW::Mechanize::PSGI;
14         #Test::WWW::Mechanize::Catalyst->VERSION(0.51);
15     }
16     or plan skip_all =>
17         'Test::WWW::Mechanize::PSGI is required for this test';
18
19     eval { require Catalyst::Plugin::Authentication; 1 }
20       or plan skip_all => "Catalyst::Plugin::Authentication is required for this test";
21
22     plan tests => 12;
23 }
24
25 use lib "t/lib";
26 use Test::WWW::Mechanize::PSGI;
27 use SessionTestApp;
28 my $ua = Test::WWW::Mechanize::PSGI->new(
29   app => SessionTestApp->psgi_app(@_),
30   cookie_jar => {}
31 );
32
33 # Test without delete __address
34 local $ENV{REMOTE_ADDR} = "192.168.1.1";
35
36 $ua->get_ok( "http://localhost/login" );
37 $ua->content_contains('logged in');
38
39 $ua->get_ok( "http://localhost/set_session_variable/logged/in" );
40 $ua->content_contains('session variable set');
41
42
43 # Change Client
44 use Plack::Builder;
45 my $app = SessionTestApp->psgi_app(@_);
46 my $ua2 = Test::WWW::Mechanize::PSGI->new(
47     app => $app,
48     cookie_jar => {}
49 );
50 $ua2->get_ok( "http://localhost/get_session_variable/logged");
51 $ua2->content_contains('VAR_logged=n.a.');
52
53 # Inital Client
54 local $ENV{REMOTE_ADDR} = "192.168.1.1";
55
56 $ua->get_ok( "http://localhost/login_without_address" );
57 $ua->content_contains('logged in (without address)');
58
59 $ua->get_ok( "http://localhost/set_session_variable/logged/in" );
60 $ua->content_contains('session variable set');
61
62 # Change Client
63 local $ENV{REMOTE_ADDR} = "192.168.1.2";
64
65 $ua->get_ok( "http://localhost/get_session_variable/logged" );
66 $ua->content_contains('VAR_logged=in');
67
68
69