C::Plugin::Session - branche for verify_user_agent option
[catagits/Catalyst-Plugin-Session.git] / t / live_verify_user_agent.t
CommitLineData
06c621b5 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7
8BEGIN {
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 { require Test::WWW::Mechanize::Catalyst }
14 or plan skip_all =>
15 "Test::WWW::Mechanize::Catalyst is required for this test";
16
17 plan tests => 12;
18}
19
20use lib "t/lib";
21use Test::WWW::Mechanize::Catalyst "SessionTestApp";
22
23my $ua = Test::WWW::Mechanize::Catalyst->new( { agent => 'Initial user_agent'} );
24$ua->get_ok( "http://localhost/user_agent", "get initial user_agent" );
25$ua->content_contains( "UA=Initial user_agent", "test initial user_agent" );
26
27$ua->get_ok( "http://localhost/page", "initial get main page" );
28$ua->content_contains( "please login", "ua not logged in" );
29
30$ua->get_ok( "http://localhost/login", "log ua in" );
31$ua->content_contains( "logged in", "ua logged in" );
32
33$ua->get_ok( "http://localhost/page", "get main page" );
34$ua->content_contains( "you are logged in", "ua logged in" );
35
36$ua->agent('Changed user_agent');
37$ua->get_ok( "http://localhost/user_agent", "get changed user_agent" );
38$ua->content_contains( "UA=Changed user_agent", "test changed user_agent" );
39
40$ua->get_ok( "http://localhost/page", "test deleted session" );
41$ua->content_contains( "please login", "ua not logged in" );