9 eval { require Catalyst::Plugin::Session::State::Cookie; Catalyst::Plugin::Session::State::Cookie->VERSION(0.03) }
11 "Catalyst::Plugin::Session::State::Cookie 0.03 or higher is required for this test";
14 require Test::WWW::Mechanize::Catalyst;
15 Test::WWW::Mechanize::Catalyst->VERSION(0.51);
18 'Test::WWW::Mechanize::Catalyst >= 0.51 is required for this test';
24 use Test::WWW::Mechanize::Catalyst "SessionTestApp";
26 my $ua1 = Test::WWW::Mechanize::Catalyst->new;
27 my $ua2 = Test::WWW::Mechanize::Catalyst->new;
29 $_->get_ok( "http://localhost/page", "initial get" ) for $ua1, $ua2;
31 $ua1->content_contains( "please login", "ua1 not logged in" );
32 $ua2->content_contains( "please login", "ua2 not logged in" );
34 $ua1->get_ok( "http://localhost/login", "log ua1 in" );
35 $ua1->content_contains( "logged in", "ua1 logged in" );
37 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
39 $ua1->content_contains( "you are logged in", "ua1 logged in" );
40 $ua2->content_contains( "please login", "ua2 not logged in" );
42 $ua2->get_ok( "http://localhost/login", "get main page" );
43 $ua2->content_contains( "logged in", "log ua2 in" );
45 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
47 $ua1->content_contains( "you are logged in", "ua1 logged in" );
48 $ua2->content_contains( "you are logged in", "ua2 logged in" );
50 my ( $u1_expires ) = ($ua1->content =~ /(\d+)$/);
51 my ( $u2_expires ) = ($ua2->content =~ /(\d+)$/);
55 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
57 $ua1->content_contains( "you are logged in", "ua1 logged in" );
58 $ua2->content_contains( "you are logged in", "ua2 logged in" );
60 my ( $u1_expires_updated ) = ($ua1->content =~ /(\d+)$/);
61 my ( $u2_expires_updated ) = ($ua2->content =~ /(\d+)$/);
63 cmp_ok( $u1_expires, "<", $u1_expires_updated, "expiry time updated");
64 cmp_ok( $u2_expires, "<", $u2_expires_updated, "expiry time updated");
66 $ua2->get_ok( "http://localhost/logout", "log ua2 out" );
67 $ua2->content_like( qr/logged out/, "ua2 logged out" );
68 $ua2->content_like( qr/after 2 request/,
69 "ua2 made 2 requests for page in the session" );
71 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
73 $ua1->content_contains( "you are logged in", "ua1 logged in" );
74 $ua2->content_contains( "please login", "ua2 not logged in" );
76 $ua1->get_ok( "http://localhost/logout", "log ua1 out" );
77 $ua1->content_like( qr/logged out/, "ua1 logged out" );
78 $ua1->content_like( qr/after 4 requests/,
79 "ua1 made 4 request for page in the session" );
81 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
83 $ua1->content_contains( "please login", "ua1 not logged in" );
84 $ua2->content_contains( "please login", "ua2 not logged in" );
86 diag("Testing against Catalyst $Catalyst::VERSION");
87 diag("Testing Catalyst::Plugin::Session $Catalyst::Plugin::Session::VERSION");