merged conflicts
[catagits/Catalyst-Runtime.git] / t / aggregate / live_component_controller_action_private.t
1 use strict;
2 use warnings;
3
4 use FindBin;
5 use lib "$FindBin::Bin/../lib";
6
7 our $iters;
8
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
10
11 use Test::More tests => 24*$iters;
12 use Catalyst::Test 'TestApp';
13
14 if ( $ENV{CAT_BENCHMARK} ) {
15     require Benchmark;
16     Benchmark::timethis( $iters, \&run_tests );
17 }
18 else {
19     for ( 1 .. $iters ) {
20         run_tests();
21     }
22 }
23
24 sub run_tests {
25     {
26         ok( my $response = request('http://localhost/action/private/one'),
27             'Request' );
28         ok( $response->is_success, 'Response Successful 2xx' );
29         is( $response->content_type, 'text/plain', 'Response Content-Type' );
30         is(
31             $response->header('X-Test-Class'),
32             'TestApp::Controller::Action::Private',
33             'Test Class'
34         );
35         is( $response->content, 'access denied', 'Access' );
36     }
37
38     {
39         ok( my $response = request('http://localhost/action/private/two'),
40             'Request' );
41         ok( $response->is_success, 'Response Successful 2xx' );
42         is( $response->content_type, 'text/plain', 'Response Content-Type' );
43         is(
44             $response->header('X-Test-Class'),
45             'TestApp::Controller::Action::Private',
46             'Test Class'
47         );
48         is( $response->content, 'access denied', 'Access' );
49     }
50
51     {
52         ok( my $response = request('http://localhost/three'), 'Request' );
53         ok( $response->is_error, 'Response Server Error 5xx' );
54         is( $response->content_type, 'text/html', 'Response Content-Type' );
55         like(
56             $response->header('X-Catalyst-Error'),
57             qr/^Unknown resource "three"/,
58             'Catalyst Error'
59         );
60     }
61
62     {
63         ok( my $response = request('http://localhost/action/private/four'),
64             'Request' );
65         ok( $response->is_success, 'Response Successful 2xx' );
66         is( $response->content_type, 'text/plain', 'Response Content-Type' );
67         is(
68             $response->header('X-Test-Class'),
69             'TestApp::Controller::Action::Private',
70             'Test Class'
71         );
72         is( $response->content, 'access denied', 'Access' );
73     }
74
75     {
76         ok( my $response = request('http://localhost/action/private/five'),
77             'Request' );
78         ok( $response->is_success, 'Response Successful 2xx' );
79         is( $response->content_type, 'text/plain', 'Response Content-Type' );
80         is(
81             $response->header('X-Test-Class'),
82             'TestApp::Controller::Action::Private',
83             'Test Class'
84         );
85         is( $response->content, 'access denied', 'Access' );
86     }
87 }