Commit | Line | Data |
2a1463db |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | |
8 | BEGIN { |
9 | eval { require Catalyst::Plugin::Session::State::Cookie; Catalyst::Plugin::Session::State::Cookie->VERSION(0.03) } |
10 | or plan skip_all => |
11 | "Catalyst::Plugin::Session::State::Cookie 0.03 or higher is required for this test"; |
12 | |
13 | eval { |
14 | require Test::WWW::Mechanize::Catalyst; |
15 | Test::WWW::Mechanize::Catalyst->VERSION(0.51); |
16 | } |
17 | or plan skip_all => |
18 | 'Test::WWW::Mechanize::Catalyst >= 0.51 is required for this test'; |
19 | |
20 | plan tests => 12; |
21 | } |
22 | |
23 | use lib "t/lib"; |
24 | use Test::WWW::Mechanize::Catalyst "SessionTestApp"; |
25 | |
26 | # Test without delete __address |
27 | local $ENV{REMOTE_ADDR} = "192.168.1.1"; |
28 | |
29 | my $ua = Test::WWW::Mechanize::Catalyst->new( {} ); |
30 | $ua->get_ok( "http://localhost/login" ); |
31 | $ua->content_contains('logged in'); |
32 | |
33 | $ua->get_ok( "http://localhost/set_session_variable/logged/in" ); |
34 | $ua->content_contains('session variable set'); |
35 | |
36 | |
37 | # Change Client |
38 | local $ENV{REMOTE_ADDR} = "192.168.1.2"; |
39 | |
40 | $ua->get_ok( "http://localhost/get_session_variable/logged"); |
41 | $ua->content_contains('VAR_logged=n.a.'); |
42 | |
43 | # Inital Client |
44 | local $ENV{REMOTE_ADDR} = "192.168.1.1"; |
45 | |
46 | $ua->get_ok( "http://localhost/login_without_address" ); |
47 | $ua->content_contains('logged in (without address)'); |
48 | |
49 | $ua->get_ok( "http://localhost/set_session_variable/logged/in" ); |
50 | $ua->content_contains('session variable set'); |
51 | |
52 | # Change Client |
53 | local $ENV{REMOTE_ADDR} = "192.168.1.2"; |
54 | |
55 | $ua->get_ok( "http://localhost/get_session_variable/logged" ); |
56 | $ua->content_contains('VAR_logged=in'); |
57 | |
58 | |
59 | |