File: | t/6-security.t |
Coverage: | 98.1% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | 1 1 1 | 1272034662998704 12942 10 | use Test::More; | ||||
2 | 1 1 1 | 461 2098 6 | use Test::Exception; | ||||
3 | 1 1 1 | 348 934167 19 | use Catalyst (); | ||||
4 | 1 1 1 | 215 927 32 | use FindBin; | ||||
5 | 1 1 1 | 168 130088 19 | use DateTime; | ||||
6 | 1 1 1 | 4 1 48 | use DateTime::Duration; | ||||
7 | |||||||
8 | 1 | 440038 | plan skip_all => 'this test is skipped under windows' if ($^O =~ m{Win}xms); | ||||
9 | |||||||
10 | # a simple package | ||||||
11 | { | ||||||
12 | 1 | 1 | package MyApp::Controller::Js; | ||||
13 | 1 1 1 | 4 1 10 | use Moose; | ||||
14 | 1 | 9 | extends 'Catalyst::Controller::Combine'; | ||||
15 | |||||||
16 | 1 | 2801 | __PACKAGE__->config( | ||||
17 | # expire => 1, | ||||||
18 | # expire_in => 60 * 60, # 1 hour | ||||||
19 | ); | ||||||
20 | } | ||||||
21 | |||||||
22 | # setup our Catalyst :-) | ||||||
23 | 1 | 213 | my $c = Catalyst->new(); | ||||
24 | 1 | 369 | $c->setup_log(); | ||||
25 | 1 | 899 | $c->setup_home("$FindBin::Bin"); | ||||
26 | |||||||
27 | 1 | 701 | my $controller; | ||||
28 | 1 1 | 18 94 | lives_ok { $controller = $c->setup_component('MyApp::Controller::Js') } 'setup component worked'; | ||||
29 | |||||||
30 | |||||||
31 | # | ||||||
32 | # check if expires header is sent, if feature isn't turned on | ||||||
33 | # | ||||||
34 | 1 | 337 | $c->response->body(''); | ||||
35 | 1 1 | 200 83 | lives_ok { $controller->do_combine($c, 'js1') } 'file inside root_dir lives'; | ||||
36 | |||||||
37 | 1 | 278 | $c->response->body(''); | ||||
38 | 1 1 | 44 81 | dies_ok { $controller->do_combine($c, 'js1', '../../../6-security.t') } 'file outside root_dir dies'; | ||||
39 | |||||||
40 | 1 | 1817 | $c->response->body(''); | ||||
41 | 1 1 | 42 78 | lives_ok { $controller->do_combine($c, 'js1', '../../../xx_notexisting.js') } 'not existing file outside root_dir lives'; | ||||
42 | |||||||
43 | 1 | 252 | done_testing; |