b15c4d7df7f7dbf94515bf35b14a4fc0b2d3fcf8
[catagits/Catalyst-Runtime.git] / t / live_engine_request_auth.t
1 #!perl
2
3 # This tests to make sure the Authorization header is passed through by the engine.
4
5 use strict;
6 use warnings;
7
8 use FindBin;
9 use lib "$FindBin::Bin/lib";
10
11 use Test::More tests => 7;
12 use Catalyst::Test 'TestApp';
13
14 use Catalyst::Request;
15 use HTTP::Headers;
16 use HTTP::Request::Common;
17
18 {
19     my $creq;
20
21     my $request = GET(
22         'http://localhost/dump/request',
23         'Authorization' => 'Basic dGVzdDoxMjM0NQ==',
24     );
25
26     ok( my $response = request($request), 'Request' );
27     ok( $response->is_success, 'Response Successful 2xx' );
28     is( $response->content_type, 'text/plain', 'Response Content-Type' );
29     like( $response->content, qr/'Catalyst::Request'/,
30         'Content is a serialized Catalyst::Request' );
31
32     {
33         no strict 'refs';
34         ok(
35             eval '$creq = ' . $response->content,
36             'Unserialize Catalyst::Request'
37         );
38     }
39
40     isa_ok( $creq, 'Catalyst::Request' );
41     
42     is( $creq->header('Authorization'), 'Basic dGVzdDoxMjM0NQ==', 'auth header ok' );
43 }