Commit | Line | Data |
300eb468 |
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 } |
10 | or plan skip_all => |
11 | "Catalyst::Plugin::Session::State::Cookie 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"; |
45c0711b |
16 | |
300eb468 |
17 | plan tests => 30; |
18 | } |
19 | |
20 | use lib "t/lib"; |
21 | use Test::WWW::Mechanize::Catalyst "SessionTestApp"; |
22 | |
23 | my $ua1 = Test::WWW::Mechanize::Catalyst->new; |
24 | my $ua2 = Test::WWW::Mechanize::Catalyst->new; |
25 | |
45c0711b |
26 | $_->get_ok( "http://localhost/page", "initial get" ) for $ua1, $ua2; |
300eb468 |
27 | |
28 | $ua1->content_contains( "please login", "ua1 not logged in" ); |
29 | $ua2->content_contains( "please login", "ua2 not logged in" ); |
30 | |
45c0711b |
31 | $ua1->get_ok( "http://localhost/login", "log ua1 in" ); |
300eb468 |
32 | $ua1->content_contains( "logged in", "ua1 logged in" ); |
33 | |
45c0711b |
34 | $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2; |
300eb468 |
35 | |
36 | $ua1->content_contains( "you are logged in", "ua1 logged in" ); |
37 | $ua2->content_contains( "please login", "ua2 not logged in" ); |
38 | |
45c0711b |
39 | $ua2->get_ok( "http://localhost/login", "get main page" ); |
300eb468 |
40 | $ua2->content_contains( "logged in", "log ua2 in" ); |
41 | |
45c0711b |
42 | $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2; |
300eb468 |
43 | |
44 | $ua1->content_contains( "you are logged in", "ua1 logged in" ); |
45 | $ua2->content_contains( "you are logged in", "ua2 logged in" ); |
46 | |
45c0711b |
47 | $ua2->get_ok( "http://localhost/logout", "log ua2 out" ); |
300eb468 |
48 | $ua2->content_like( qr/logged out/, "ua2 logged out" ); |
45c0711b |
49 | $ua2->content_like( qr/after 1 request/, |
50 | "ua2 made 1 request for page in the session" ); |
300eb468 |
51 | |
45c0711b |
52 | $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2; |
300eb468 |
53 | |
54 | $ua1->content_contains( "you are logged in", "ua1 logged in" ); |
55 | $ua2->content_contains( "please login", "ua2 not logged in" ); |
56 | |
45c0711b |
57 | $ua1->get_ok( "http://localhost/logout", "log ua1 out" ); |
300eb468 |
58 | $ua1->content_like( qr/logged out/, "ua1 logged out" ); |
45c0711b |
59 | $ua1->content_like( qr/after 3 requests/, |
60 | "ua1 made 3 request for page in the session" ); |
300eb468 |
61 | |
45c0711b |
62 | $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2; |
300eb468 |
63 | |
64 | $ua1->content_contains( "please login", "ua1 not logged in" ); |
65 | $ua2->content_contains( "please login", "ua2 not logged in" ); |
66 | |