Fix RT#81506
[catagits/Catalyst-Plugin-Session.git] / t / live_verify_address.t
CommitLineData
2a1463db 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
2a1463db 7BEGIN {
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
25use lib "t/lib";
83a3f0e9 26use Test::WWW::Mechanize::PSGI;
27use SessionTestApp;
28my $ua = Test::WWW::Mechanize::PSGI->new(
29 app => SessionTestApp->psgi_app(@_),
30 cookie_jar => {}
31);
2a1463db 32
33# Test without delete __address
34local $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 44use Plack::Builder;
45my $app = SessionTestApp->psgi_app(@_);
83a3f0e9 46my $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
54local $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 63local $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