File: not-found.t

package info (click to toggle)
libmojolicious-plugin-assetpack-perl 2.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: perl: 1,503; javascript: 52; makefile: 8; sh: 2
file content (41 lines) | stat: -rw-r--r-- 1,440 bytes parent folder | download | duplicates (3)
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
use lib '.';
use t::Helper;

my $t = t::Helper->t(pipes => [qw(Css Combine)]);
eval { $t->app->asset->process };
like $@, qr{Could not find input asset "no-such-stylesheet\.css"}, 'could not find asset';

$t->app->asset->process('something.png', 'image/sample.png');
$t->app->asset->process('app.css',       'input.css');

$t->get_ok('/')->status_is(200)->element_exists(qq(link[href="/asset/f956a3f925/input.css"]));

# Valid request
$t->get_ok('/asset/f956a3f925/input.css')->status_is(200);

# TODO: /:name is ignored. This might need to change
$t->get_ok('/asset/f956a3f925/foo.css')->status_is(200);

# This is useful when assets are combined
$t->get_ok('/asset/aaaaaaaaaa/app.css')->status_is(200)->content_is(qq(\@import "/asset/f956a3f925/input.css";\n));

# Both checksum and topic is invalid
$t->get_ok('/asset/aaaaaaaaaa/foo.css')->status_is(404)->content_is("// No such asset 'foo.css'\n");

$t->get_ok('/asset/aaaaaaaaaa/something.png')->status_is(302)->header_like(Location => qr{^/asset/\w+/something.png$});
$t->get_ok($t->tx->res->headers->location)->status_is(200);

# XSS attack
$t->get_ok('/asset/aaaaaaaaaa/foo.xml%3Cscript%3Ealert(\'ouch\')%3C/script%3E')->status_is(404)
  ->content_is("// No such asset 'foo.xml<script>alert('ouch')</script>'\n");

done_testing;

__DATA__
@@ assetpack.def
! app.css
< no-such-stylesheet.css
@@ index.html.ep
%= asset 'app.css'
@@ input.css
.one { color: #111; }