Commit | Line | Data |
2a1463db |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
2a1463db |
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 { |
83a3f0e9 |
13 | require Test::WWW::Mechanize::PSGI; |
14 | #Test::WWW::Mechanize::Catalyst->VERSION(0.51); |
2a1463db |
15 | } |
16 | or plan skip_all => |
83a3f0e9 |
17 | 'Test::WWW::Mechanize::PSGI is required for this test'; |
2a1463db |
18 | |
d7cb2327 |
19 | eval { require Catalyst::Plugin::Authentication; 1 } |
20 | or plan skip_all => "Catalyst::Plugin::Authentication is required for this test"; |
21 | |
2a1463db |
22 | plan tests => 12; |
23 | } |
24 | |
25 | use lib "t/lib"; |
83a3f0e9 |
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 | ); |
2a1463db |
32 | |
33 | # Test without delete __address |
34 | local $ENV{REMOTE_ADDR} = "192.168.1.1"; |
35 | |
2a1463db |
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 | |
32f97098 |
43 | # Change Client |
83a3f0e9 |
44 | use Plack::Builder; |
45 | my $app = SessionTestApp->psgi_app(@_); |
83a3f0e9 |
46 | my $ua2 = Test::WWW::Mechanize::PSGI->new( |
47 | app => $app, |
48 | cookie_jar => {} |
32f97098 |
49 | ); |
83a3f0e9 |
50 | $ua2->get_ok( "http://localhost/get_session_variable/logged"); |
51 | $ua2->content_contains('VAR_logged=n.a.'); |
2a1463db |
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 | |
32f97098 |
62 | # Change Client |
2a1463db |
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 | |