| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More tests=>1; |
| 4 |
use Plack::Test; |
| 5 |
use HTTP::Request::Common; |
| 6 |
use JSON::MaybeXS; |
| 7 |
|
| 8 |
{ |
| 9 |
|
| 10 |
package ContentLengthTestApp; |
| 11 |
use Dancer2; |
| 12 |
set serializer => 'JSON'; |
| 13 |
|
| 14 |
post '/foo' => sub { |
| 15 |
forward('/not_authorized'); |
| 16 |
}; |
| 17 |
|
| 18 |
any '/not_authorized' => sub { |
| 19 |
status 401; |
| 20 |
{ access => 'denied' }; |
| 21 |
}; |
| 22 |
} |
| 23 |
|
| 24 |
{ |
| 25 |
my $url = 'http://localhost'; |
| 26 |
my $test = Plack::Test->create( ContentLengthTestApp->to_app ); |
| 27 |
|
| 28 |
my $response = $test->request( |
| 29 |
POST( |
| 30 |
'/foo', |
| 31 |
Content => |
| 32 |
encode_json( { target => [ 'foo', 'bar' ] } ), |
| 33 |
) |
| 34 |
); |
| 35 |
|
| 36 |
is( $response->code, 401, 'Access denied to unauthorized merge' ); |
| 37 |
|
| 38 |
} |