annotate h2_http2.t @ 1907:034c9121b9d1

Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL. Those libraries provide an older callback order, where ALPN callback is invoked before SNI callback. Additionally, OpenSSL 1.0.2 doesn't send alert on ALPN mismatch.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 08 Jun 2023 16:41:11 +0400
parents c560f5da581e
children 79ca9ab75310
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1902
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 is(get_https(8443, 'http2'), 200, 'host to enabled');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 is(get_https(8443, 'disabled', 'http2'), 421, 'host to disabled');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 # make sure HTTP/2 can be enabled selectively on virtual servers
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134
1907
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
135 TODO: {
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
136 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
137 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
138 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
139
1902
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 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
141
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
142 }
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
143
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
144 TODO: {
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
145 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
146 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
147 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
148 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
149 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
150
1902
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 is(get_https(8444, 'http2'), 200, 'sni to enabled');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152
1907
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
153 }
034c9121b9d1 Tests: added h2_http2.t TODOs for LibreSSL and older OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1902
diff changeset
154
1902
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 # http2 detection on plain tcp socket by connection preface
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 like(http_get('/'), qr/200 OK/, 'non-ssl http');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 is(get_http(8080), 200, 'non-ssl http2');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 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
161 qr/200 OK/, 'non-ssl http deprecated');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 is(get_http(8081), 200, 'non-ssl http2 deprecated');
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 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
165 select undef, undef, undef, 0.2;
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166 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
167 'preface with multiple packets');
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 ###############################################################################
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 sub get_http {
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 my ($port, $host, $sock, $preface) = @_;
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 my $s = Test::Nginx::HTTP2->new(port($port),
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174 socket => $sock, preface => $preface);
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 my $sid = $s->new_stream({ host => $host });
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
178 return $frame->{headers}->{':status'};
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
179 }
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
180
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
181 sub get_https {
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
182 my ($port, $host, $sni, $alpn) = @_;
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
183 my $sock = get_ssl_socket($port, $sni || $host, $alpn);
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
184 return get_http($port, $host, $sock);
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
185 }
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 sub get_ssl_socket {
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
188 my ($port, $sni, $alpn) = @_;
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
189 return http('', PeerAddr => '127.0.0.1:' . port($port), start => 1,
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
190 SSL => 1,
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
191 SSL_hostname => $sni,
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
192 SSL_alpn_protocols => $alpn || ['h2']);
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
c560f5da581e Tests: http2 directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
195 ###############################################################################