-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlive_expiry_threshold.t
71 lines (46 loc) · 1.94 KB
/
live_expiry_threshold.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use strict;
use warnings;
use Test::Needs {
'Catalyst::Plugin::Authentication' => '0',
'Catalyst::Plugin::Session::State::Cookie' => '0.03',
};
use Test::More;
use lib "t/lib";
use MiniUA;
my $ua = MiniUA->new('SessionExpiry');
my $res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");
my $expiry = $res->decoded_content + 0;
$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $expiry, "session_expires == session_data_expires");
sleep(1);
$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");
is($res->decoded_content, $expiry, "expiration not updated");
$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $expiry, "session_expires == session_data_expires");
#
$res = $ua->get( "http://localhost/update_session" );
ok($res->is_success, "update_session");
$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");
my $updated = $res->decoded_content + 0;
ok($updated > $expiry, "expiration updated");
$expiry = $updated;
$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");
is($res->decoded_content, $expiry, "expiration not updated");
$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $expiry, "session_expires == session_data_expires");
sleep(10);
$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");
$updated = $res->decoded_content + 0;
ok($updated > $expiry, "expiration updated");
$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $updated, "session_expires == session_data_expires");
done_testing;