Commit | Line | Data |
0421e89a |
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 { |
14 | require Test::WWW::Mechanize::Catalyst; |
15 | Test::WWW::Mechanize::Catalyst->VERSION(0.51); |
16 | } |
17 | or plan skip_all => |
18 | 'Test::WWW::Mechanize::Catalyst >= 0.51 is required for this test'; |
19 | } |
20 | |
21 | use lib "t/lib"; |
079b2fbe |
22 | use Test::WWW::Mechanize::Catalyst "SessionExpiry"; |
0421e89a |
23 | |
24 | my $ua = Test::WWW::Mechanize::Catalyst->new; |
25 | |
079b2fbe |
26 | my $res = $ua->get( "http://localhost/session_data_expires" ); |
27 | ok($res->is_success, "session_data_expires"); |
0421e89a |
28 | |
079b2fbe |
29 | my $expiry = $res->decoded_content + 0; |
30 | |
31 | $res = $ua->get( "http://localhost/session_expires" ); |
32 | ok($res->is_success, "session_expires"); |
33 | is($res->decoded_content, $expiry, "session_expires == session_data_expires"); |
0421e89a |
34 | |
35 | sleep(1); |
36 | |
079b2fbe |
37 | $res = $ua->get( "http://localhost/session_data_expires" ); |
38 | ok($res->is_success, "session_data_expires"); |
0421e89a |
39 | |
40 | is($res->decoded_content, $expiry, "expiration not updated"); |
41 | |
079b2fbe |
42 | $res = $ua->get( "http://localhost/session_expires" ); |
43 | ok($res->is_success, "session_expires"); |
44 | is($res->decoded_content, $expiry, "session_expires == session_data_expires"); |
45 | |
0421e89a |
46 | sleep(10); |
47 | |
079b2fbe |
48 | $res = $ua->get( "http://localhost/session_data_expires" ); |
49 | ok($res->is_success, "session_data_expires"); |
50 | |
51 | my $updated = $res->decoded_content + 0; |
52 | ok($updated > $expiry, "expiration updated"); |
53 | |
54 | $res = $ua->get( "http://localhost/session_expires" ); |
55 | ok($res->is_success, "session_expires"); |
56 | is($res->decoded_content, $updated, "session_expires == session_data_expires"); |
0421e89a |
57 | |
0421e89a |
58 | |
59 | done_testing; |