Mercurial > hg > nginx-tests
comparison h2_auth_request.t @ 1088:83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Previously, a request body bigger than "client_body_buffer_size"
might result in sending corrupted body or cause a segfault.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 06 Dec 2016 15:19:27 +0300 |
parents | |
children | 9d6a0dbb889a |
comparison
equal
deleted
inserted
replaced
1087:534d209f6ae4 | 1088:83b7b3f8b6c5 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Andrey Zelenkov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for HTTP/2 protocol with auth_request. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::HTTP2; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite proxy auth_request/) | |
27 ->plan(2); | |
28 | |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | |
30 | |
31 %%TEST_GLOBALS%% | |
32 | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080 http2; | |
43 listen 127.0.0.1:8081; | |
44 server_name localhost; | |
45 | |
46 location / { | |
47 return 200; | |
48 } | |
49 location /auth { | |
50 add_header X-Body-File $request_body_file; | |
51 client_body_buffer_size 512; | |
52 auth_request /auth_request; | |
53 proxy_pass http://127.0.0.1:8081/auth_proxy; | |
54 } | |
55 location /auth_request { | |
56 proxy_pass http://127.0.0.1:8081/; | |
57 proxy_pass_request_body off; | |
58 proxy_set_header Content-Length ""; | |
59 } | |
60 location /auth_proxy { | |
61 add_header X-Body $request_body; | |
62 proxy_pass http://127.0.0.1:8081/; | |
63 } | |
64 } | |
65 } | |
66 | |
67 EOF | |
68 | |
69 $t->run(); | |
70 | |
71 ############################################################################### | |
72 | |
73 my ($s, $sid, $frames, $frame); | |
74 | |
75 TODO: { | |
76 todo_skip 'use-after-free', 2 unless $ENV{TEST_NGINX_UNSAFE} | |
77 or $t->has_version('1.11.7'); | |
78 | |
79 # second stream is used to induce body corruption issue | |
80 | |
81 $s = Test::Nginx::HTTP2->new(); | |
82 $sid = $s->new_stream({ path => '/auth', method => 'POST', body => 'A' x 600 }); | |
83 $s->new_stream({ path => '/auth', method => 'POST', body => 'B' x 600 }); | |
84 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
85 | |
86 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
87 is($frame->{headers}->{'x-body'}, 'A' x 600, 'auth request body'); | |
88 isnt($frame->{headers}->{'x-body-file'}, undef, 'auth request body file'); | |
89 | |
90 } | |
91 | |
92 ############################################################################### |