File: live_engine_response_cookies.t

package info (click to toggle)
libcatalyst-engine-apache-perl 1.12-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 700 kB
  • ctags: 498
  • sloc: perl: 6,003; makefile: 45
file content (73 lines) | stat: -rw-r--r-- 2,203 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
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
72
73
#!perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/lib";

use Test::More tests => 15;
use Catalyst::Test 'TestApp';
use HTTP::Headers::Util 'split_header_words';

my $expected = {
    Catalyst => [qw|Catalyst Cool path /bah|],
    Cool     => [qw|Cool Catalyst path /|]
};

{
    ok( my $response = request('http://localhost/engine/response/cookies/one'),
        'Request' );
    ok( $response->is_success, 'Response Successful 2xx' );
    is( $response->content_type, 'text/plain', 'Response Content-Type' );
    is( $response->header('X-Catalyst-Action'),
        'engine/response/cookies/one', 'Test Action' );

    my $cookies = {};

    for my $string ( $response->header('Set-Cookie') ) {
        my $cookie = [ split_header_words $string];
        $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
    }

    is_deeply( $cookies, $expected, 'Response Cookies' );
}

{
    ok( my $response = request('http://localhost/engine/response/cookies/two'),
        'Request' );
    ok( $response->is_redirect, 'Response Redirection 3xx' );
    is( $response->code, 302, 'Response Code' );
    is( $response->header('X-Catalyst-Action'),
        'engine/response/cookies/two', 'Test Action' );

    my $cookies = {};

    for my $string ( $response->header('Set-Cookie') ) {
        my $cookie = [ split_header_words $string];
        $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
    }

    is_deeply( $cookies, $expected, 'Response Cookies' );
}

{
    ok( my $response = request('http://localhost/engine/response/cookies/three'),
        'Request' );
    ok( $response->is_success, 'Response Successful 2xx' );
    is( $response->content_type, 'text/plain', 'Response Content-Type' );
    is( $response->header('X-Catalyst-Action'),
        'engine/response/cookies/three', 'Test Action' );

    my $cookies = {};

    for my $string ( $response->header('Set-Cookie') ) {
        my $cookie = [ split_header_words $string];
        $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
    }

    is_deeply( $cookies, {
        hash => [ qw(hash a&b&c path /) ],
        this_is_the_real_name => [ qw(this_is_the_real_name foo&bar path /) ], # not "object"
    }, 'Response Cookies' );
}