C::Plugin::Session - branche for verify_user_agent option
[catagits/Catalyst-Plugin-Session.git] / t / live_verify_user_agent.t
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 { 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
20 use lib "t/lib";
21 use Test::WWW::Mechanize::Catalyst "SessionTestApp";
22
23 my $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" );