Chop out crap that is not needed
[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     plan tests => 12;
20 }
21
22 use lib "t/lib";
23 use Test::WWW::Mechanize::PSGI;
24 use SessionTestApp;
25 my $ua = Test::WWW::Mechanize::PSGI->new(
26   app => SessionTestApp->psgi_app(@_),
27   cookie_jar => {}
28 );
29
30 # Test without delete __address
31 local $ENV{REMOTE_ADDR} = "192.168.1.1";
32
33 $ua->get_ok( "http://localhost/login" );
34 $ua->content_contains('logged in');
35
36 $ua->get_ok( "http://localhost/set_session_variable/logged/in" );
37 $ua->content_contains('session variable set');
38
39
40 # Change Client
41 use Plack::Builder;
42 my $app = SessionTestApp->psgi_app(@_);
43 my $ua2 = Test::WWW::Mechanize::PSGI->new(
44     app => $app,
45     cookie_jar => {}
46 );
47 $ua2->get_ok( "http://localhost/get_session_variable/logged");
48 $ua2->content_contains('VAR_logged=n.a.');
49
50 # Inital Client
51 local $ENV{REMOTE_ADDR} = "192.168.1.1";
52
53 $ua->get_ok( "http://localhost/login_without_address" );
54 $ua->content_contains('logged in (without address)');
55
56 $ua->get_ok( "http://localhost/set_session_variable/logged/in" );
57 $ua->content_contains('session variable set');
58
59 # Change Client
60 local $ENV{REMOTE_ADDR} = "192.168.1.2";
61
62 $ua->get_ok( "http://localhost/get_session_variable/logged" );
63 $ua->content_contains('VAR_logged=in');
64
65
66