Mercurial > hg > nginx-tests
annotate h3_server_tokens.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 78452573505c |
children |
rev | line source |
---|---|
1892
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/3 protocol with server_tokens directive. |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP3; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1896
8b74936ff2ac
Tests: added has_feature() test for CryptX.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1892
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v3 rewrite cryptx/) |
1892
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has_daemon('openssl')->plan(12); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 ssl_certificate_key localhost.key; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 ssl_certificate localhost.crt; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 listen 127.0.0.1:%%PORT_8980_UDP%% quic; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server_name localhost; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location /200 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 return 200; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 location /404 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 return 404; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 location /off { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server_tokens off; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 location /off/200 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 return 200; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /off/404 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 return 404; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 location /on { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 server_tokens on; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 location /on/200 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 return 200; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 location /on/404 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 return 404; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 location /b { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 server_tokens build; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 location /b/200 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 return 200; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 location /b/404 { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 return 404; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 EOF |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 $t->write_file('openssl.conf', <<EOF); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 [ req ] |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 default_bits = 2048 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 encrypt_key = no |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 distinguished_name = req_distinguished_name |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 [ req_distinguished_name ] |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 EOF |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 my $d = $t->testdir(); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 foreach my $name ('localhost') { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 system('openssl req -x509 -new ' |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 . "-config $d/openssl.conf -subj /CN=$name/ " |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 . "-out $d/$name.crt -keyout $d/$name.key " |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 . ">>$d/openssl.out 2>&1") == 0 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 or die "Can't create certificate for $name: $!\n"; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 $t->run(); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 ############################################################################### |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
1948
78452573505c
Tests: improved server tokens tests to accept alternative names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
118 my $re = qr/\w+\/\d+\.\d+\.\d+/; |
1892
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 like(header_server('/200'), qr/^$re$/, 'http3 tokens default 200'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 like(header_server('/404'), qr/^$re$/, 'http3 tokens default 404'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 like(body('/404'), qr/$re/, 'http3 tokens default 404 body'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
1948
78452573505c
Tests: improved server tokens tests to accept alternative names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
124 like(header_server('/off/200'), qr/^\w+$/, 'http3 tokens off 200'); |
78452573505c
Tests: improved server tokens tests to accept alternative names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
125 like(header_server('/off/404'), qr/^\w+$/, 'http3 tokens off 404'); |
78452573505c
Tests: improved server tokens tests to accept alternative names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1896
diff
changeset
|
126 unlike(body('/off/404'), $re, 'http3 tokens off 404 body'); |
1892
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 like(header_server('/on/200'), qr/^$re$/, 'http3 tokens on 200'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 like(header_server('/on/404'), qr/^$re$/, 'http3 tokens on 404'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 like(body('/on/404'), $re, 'http3 tokens on 404 body'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 $re = qr/$re \(.*\)/ if $t->has_module('--build='); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 like(header_server('/b/200'), qr/^$re$/, 'http3 tokens build 200'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 like(header_server('/b/404'), qr/^$re$/, 'http3 tokens build 404'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 like(body('/b/404'), qr/$re/, 'http3 tokens build 404 body'); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 ############################################################################### |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 sub header_server { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 my ($path) = shift; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 my $s = Test::Nginx::HTTP3->new(); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 my $sid = $s->new_stream({ path => $path }); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 return $frame->{headers}->{'server'}; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 sub body { |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 my ($path) = shift; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 my $s = Test::Nginx::HTTP3->new(); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 my $sid = $s->new_stream({ path => $path }); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 my ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 return $frame->{'data'}; |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 } |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
a8fc2f1f6f6f
Tests: HTTP/3 server_tokens tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 ############################################################################### |