Mercurial > hg > nginx-tests
annotate h2_http2.t @ 1926:0fb9ca9046bf
Tests: fixed variable-length encoding of QUIC Stream ID.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 14 Aug 2023 17:10:19 +0400 |
parents | 07656d303199 |
children | a095b971fbcc |
rev | line source |
---|---|
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol, http2 directive. |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 socket_ssl_alpn/) |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has_daemon('openssl'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 ssl_certificate_key localhost.key; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 ssl_certificate localhost.crt; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 listen 127.0.0.1:8443 ssl; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server_name default; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 http2 on; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 listen 127.0.0.1:8443; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 server_name http2; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 http2 on; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 listen 127.0.0.1:8443; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 server_name disabled; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 http2 off; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 listen 127.0.0.1:8444 ssl; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 server_name default; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 listen 127.0.0.1:8444; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 server_name http2; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 http2 on; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 listen 127.0.0.1:8080; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 server_name localhost; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 http2 on; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 server { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 listen 127.0.0.1:8081 http2; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 server_name localhost; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 EOF |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 $t->write_file('openssl.conf', <<EOF); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 [ req ] |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 default_bits = 2048 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 encrypt_key = no |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 distinguished_name = req_distinguished_name |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 [ req_distinguished_name ] |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 EOF |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 my $d = $t->testdir(); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 foreach my $name ('localhost') { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 system('openssl req -x509 -new ' |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 . "-config $d/openssl.conf -subj /CN=$name/ " |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 . "-out $d/$name.crt -keyout $d/$name.key " |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 . ">>$d/openssl.out 2>&1") == 0 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 or die "Can't create certificate for $name: $!\n"; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 $t->write_file('index.html', ''); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 $t->try_run('no http2')->plan(11); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 ############################################################################### |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 # make sure HTTP/2 can be disabled selectively on virtual servers |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 ok(get_ssl_socket(8443), 'default to enabled'); |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
118 |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
119 TODO: { |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
120 local $TODO = 'broken ALPN/SNI order in LibreSSL' |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
121 if $t->has_module('LibreSSL'); |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
122 local $TODO = 'OpenSSL too old' |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
123 if $t->has_module('OpenSSL') |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
124 and not $t->has_feature('openssl:1.1.0'); |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
125 |
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 ok(!get_ssl_socket(8443, 'disabled'), 'sni to disabled'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
128 } |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
129 |
1920
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
130 TODO: { |
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
131 local $TODO = 'OpenSSL too old' |
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
132 if $t->has_module('OpenSSL') |
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
133 and not $t->has_feature('openssl:1.0.2'); |
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
134 |
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 is(get_https(8443, 'http2'), 200, 'host to enabled'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 is(get_https(8443, 'disabled', 'http2'), 421, 'host to disabled'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
1920
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
138 } |
79ca9ab75310
Tests: fixed h2_http2.t when nginx compiled without ALPN support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1907
diff
changeset
|
139 |
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 # make sure HTTP/2 can be enabled selectively on virtual servers |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
142 TODO: { |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
143 local $TODO = 'OpenSSL too old' |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
144 if $t->has_module('OpenSSL') |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
145 and not $t->has_feature('openssl:1.1.0'); |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
146 |
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 ok(!get_ssl_socket(8444), 'default to disabled'); |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
148 |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
149 } |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
150 |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
151 TODO: { |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
152 local $TODO = 'broken ALPN/SNI order in LibreSSL' |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
153 if $t->has_module('LibreSSL'); |
1921
07656d303199
Tests: adjusted TODO for OpenSSL 1.0.2h and up in h2_http2.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1920
diff
changeset
|
154 local $TODO = 'broken ALPN/SNI order in OpenSSL before 1.0.2h' |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
155 if $t->has_module('OpenSSL') |
1921
07656d303199
Tests: adjusted TODO for OpenSSL 1.0.2h and up in h2_http2.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1920
diff
changeset
|
156 and not $t->has_feature('openssl:1.0.2h'); |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
157 |
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 is(get_https(8444, 'http2'), 200, 'sni to enabled'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 |
1907
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
160 } |
034c9121b9d1
Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1902
diff
changeset
|
161 |
1902
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 # http2 detection on plain tcp socket by connection preface |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 like(http_get('/'), qr/200 OK/, 'non-ssl http'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 is(get_http(8080), 200, 'non-ssl http2'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 like(http_get('/', socket => IO::Socket::INET->new('127.0.0.1:' . port(8081))), |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 qr/200 OK/, 'non-ssl http deprecated'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 is(get_http(8081), 200, 'non-ssl http2 deprecated'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 my $sock = http("PRI * HTTP/2.0\r\n\r\n", start => 1); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 select undef, undef, undef, 0.2; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 is(get_http(8080, 'localhost', $sock, "SM\r\n\r\n"), 200, |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 'preface with multiple packets'); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 ############################################################################### |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 sub get_http { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 my ($port, $host, $sock, $preface) = @_; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 my $s = Test::Nginx::HTTP2->new(port($port), |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 socket => $sock, preface => $preface); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 my $sid = $s->new_stream({ host => $host }); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 return $frame->{headers}->{':status'}; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 sub get_https { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 my ($port, $host, $sni, $alpn) = @_; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 my $sock = get_ssl_socket($port, $sni || $host, $alpn); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 return get_http($port, $host, $sock); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 sub get_ssl_socket { |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 my ($port, $sni, $alpn) = @_; |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 return http('', PeerAddr => '127.0.0.1:' . port($port), start => 1, |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 SSL => 1, |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 SSL_hostname => $sni, |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 SSL_alpn_protocols => $alpn || ['h2']); |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 } |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 |
c560f5da581e
Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 ############################################################################### |