Chop out crap that is not needed
[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
19 plan tests => 12;
20}
21
22use lib "t/lib";
83a3f0e9 23use Test::WWW::Mechanize::PSGI;
24use SessionTestApp;
25my $ua = Test::WWW::Mechanize::PSGI->new(
26 app => SessionTestApp->psgi_app(@_),
27 cookie_jar => {}
28);
2a1463db 29
30# Test without delete __address
31local $ENV{REMOTE_ADDR} = "192.168.1.1";
32
2a1463db 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
32f97098 40# Change Client
83a3f0e9 41use Plack::Builder;
42my $app = SessionTestApp->psgi_app(@_);
83a3f0e9 43my $ua2 = Test::WWW::Mechanize::PSGI->new(
44 app => $app,
45 cookie_jar => {}
32f97098 46);
83a3f0e9 47$ua2->get_ok( "http://localhost/get_session_variable/logged");
48$ua2->content_contains('VAR_logged=n.a.');
2a1463db 49
50# Inital Client
51local $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
32f97098 59# Change Client
2a1463db 60local $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