Mercurial > hg > nginx-tests
annotate h2_auth_request.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 11463d379570 |
children |
rev | line source |
---|---|
1088
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
2 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
5 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with auth_request. |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
7 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
9 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
11 use strict; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
12 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
14 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
16 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
20 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
22 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
25 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite proxy auth_request/) |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
27 ->plan(2); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
28 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
30 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
32 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
34 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
35 events { |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
36 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
37 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
38 http { |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
40 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
41 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
42 listen 127.0.0.1:8080; |
1088
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
43 listen 127.0.0.1:8081; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
44 server_name localhost; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
45 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
46 http2 on; |
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
47 |
1088
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
48 location / { |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
49 return 200; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
50 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
51 location /auth { |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
52 add_header X-Body-File $request_body_file; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
53 client_body_buffer_size 512; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
54 auth_request /auth_request; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
55 proxy_pass http://127.0.0.1:8081/auth_proxy; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
56 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
57 location /auth_request { |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
58 proxy_pass http://127.0.0.1:8081/; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
59 proxy_pass_request_body off; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
60 proxy_set_header Content-Length ""; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
61 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
62 location /auth_proxy { |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
63 add_header X-Body $request_body; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
64 proxy_pass http://127.0.0.1:8081/; |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
65 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
66 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
67 } |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
68 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
69 EOF |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
70 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
71 $t->run(); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
72 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 ############################################################################### |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
74 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
75 my ($s, $sid, $frames, $frame); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
76 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 # second stream is used to induce body corruption issue |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
78 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
79 $s = Test::Nginx::HTTP2->new(); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
80 $sid = $s->new_stream({ path => '/auth', method => 'POST', body => 'A' x 600 }); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
81 $s->new_stream({ path => '/auth', method => 'POST', body => 'B' x 600 }); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
82 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
83 |
1090
9d6a0dbb889a
Tests: check headers for appropriate stream in h2_auth_request.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1088
diff
changeset
|
84 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; |
1088
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
85 is($frame->{headers}->{'x-body'}, 'A' x 600, 'auth request body'); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
86 isnt($frame->{headers}->{'x-body-file'}, undef, 'auth request body file'); |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
87 |
83b7b3f8b6c5
Tests: added HTTP/2 tests with auth_request (ticket #1143).
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
88 ############################################################################### |