File: yaml-html.t

package info (click to toggle)
libcatalyst-action-rest-perl 1.21-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 476 kB
  • sloc: perl: 1,750; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;
use Test::More;
use Test::Requires qw(YAML::Syck);
use YAML::Syck;
use FindBin;

use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
use Test::Rest;

BEGIN {
    use_ok 'Catalyst::Test', 'Test::Serialize';
}

my $has_serializer = eval "require YAML::Syck";
SKIP: {
    skip "YAML::Syck not available", 3, unless $has_serializer;

    my $t = Test::Rest->new( 'content_type' => 'text/html' );

    my $monkey_template =
"<html><title>Test::Serialize</title><body><pre>--- \nmonkey: likes chicken!\n</pre></body></html>";
    my $mres = request( $t->get( url => '/monkey_get' ) );
    ok( $mres->is_success, 'GET the monkey succeeded' );
    is( $mres->content, $monkey_template, "GET returned the right data" );

    my $post_data = { 'sushi' => 'is good for monkey', };
    my $mres_post =
      request( $t->post( url => '/monkey_put', data => Dump($post_data) ) );
    ok( $mres_post->is_error, "POST to the monkey failed; no deserializer." );

    # xss test - RT 63537
    my $xss_template =
"<html><title>Test::Serialize</title><body><pre>--- \nmonkey: likes chicken &gt; sushi!\n</pre></body></html>";
    my $xres = request( $t->get( url => '/xss_get' ) );
    ok( $xres->is_success, 'GET the xss succeeded' );
    is( $xres->content, $xss_template, "GET returned the right data" );


}
1;

done_testing;