Commit | Line | Data |
db1cda22 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
602b9593 |
6 | use FindBin qw/$Bin/; |
7 | use lib "$Bin/lib"; |
8 | |
db1cda22 |
9 | use Test::More; |
10 | |
11 | BEGIN { |
12 | eval { require Test::WWW::Mechanize::Catalyst }; |
13 | plan skip_all => |
14 | "This test requires Test::WWW::Mechanize::Catalyst in order to run" |
15 | if $@; |
c4a96adb |
16 | plan skip_all => 'Test::WWW::Mechanize::Catalyst >= 0.40 required' if $Test::WWW::Mechanize::Catalyst::VERSION < 0.40; |
db1cda22 |
17 | plan 'no_plan'; |
18 | } |
19 | |
db1cda22 |
20 | use Test::WWW::Mechanize::Catalyst qw/CookieTestApp/; |
21 | |
22 | my $m = Test::WWW::Mechanize::Catalyst->new; |
23 | |
a79a56a8 |
24 | $m->get_ok( "http://localhost/stream", "get page" ); |
58730edc |
25 | $m->content_contains( "hit number 1", "session data created" ); |
db1cda22 |
26 | |
27 | my $expired; |
c4a96adb |
28 | $m->cookie_jar->scan( sub { $expired = $_[8]; } ); |
db1cda22 |
29 | |
a79a56a8 |
30 | $m->get_ok( "http://localhost/page", "get page" ); |
58730edc |
31 | $m->content_contains( "hit number 2", "session data restored" ); |
db1cda22 |
32 | |
a79a56a8 |
33 | $m->get_ok( "http://localhost/stream", "get stream" ); |
58730edc |
34 | $m->content_contains( "hit number 3", "session data restored" ); |
db1cda22 |
35 | |
a79a56a8 |
36 | sleep 1; |
db1cda22 |
37 | |
9013c08b |
38 | $m->get_ok( "http://localhost/stream", "get page" ); |
58730edc |
39 | $m->content_contains( "hit number 4", "session data restored" ); |
db1cda22 |
40 | |
41 | my $updated_expired; |
c4a96adb |
42 | $m->cookie_jar->scan( sub { $updated_expired = $_[8]; } ); |
58730edc |
43 | cmp_ok( $expired, "<", $updated_expired, "cookie expiration was extended" ); |
dbec0a9d |
44 | |
9013c08b |
45 | $expired = $m->cookie_jar->scan( sub { $expired = $_[8] } ); |
46 | $m->get_ok( "http://localhost/page", "get page again"); |
47 | $m->content_contains( "hit number 5", "session data restored (blah)" ); |
48 | |
49 | sleep 1; |
50 | |
51 | $m->get_ok( "http://localhost/stream", "get stream" ); |
52 | $m->content_contains( "hit number 6", "session data restored" ); |
53 | |
54 | $m->cookie_jar->scan( sub { $updated_expired = $_[8]; } ); |
55 | cmp_ok( $expired, "<", $updated_expired, "streaming also extends cookie" ); |
56 | |
a79a56a8 |
57 | $m->get_ok( "http://localhost/deleteme", "get page" ); |
dbec0a9d |
58 | $m->content_is( 1, 'session id changed' ); |