annotate h2_ssl.t @ 948:4dc302d8e04f

Tests: changed HTTP2 package to act as a class. Stopped exporting any subroutines. A subset of them now act as class methods.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 17 Jun 2016 11:36:33 +0300
parents 724fcee9a355
children e9064d691790
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
2
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
5
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
6 # Tests for HTTP/2 protocol with ssl.
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
7
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
8 ###############################################################################
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
9
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
10 use warnings;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
11 use strict;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
12
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
13 use Test::More;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
14
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
16
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
17 use lib 'lib';
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
19 use Test::Nginx::HTTP2;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
20
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
21 ###############################################################################
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
22
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
25
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
26 eval { require IO::Socket::SSL; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
27 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
28 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
29 plan(skip_all => 'IO::Socket::SSL too old') if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
30
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
31 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 rewrite/)
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
32 ->has_daemon('openssl')->plan(8);
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
33
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
34 $t->write_file_expand('nginx.conf', <<'EOF');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
35
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
36 %%TEST_GLOBALS%%
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
37
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
38 daemon off;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
39
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
40 events {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
41 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
42
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
43 http {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
44 %%TEST_GLOBALS_HTTP%%
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
45
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
46 server {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
47 listen 127.0.0.1:8081 http2 ssl;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
48 server_name localhost;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
49
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
50 ssl_certificate_key localhost.key;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
51 ssl_certificate localhost.crt;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
52
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
53 location /h2 {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
54 return 200 $http2;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
55 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
56 location /sp {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
57 return 200 $server_protocol;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
58 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
59 location /scheme {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
60 return 200 $scheme;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
61 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
62 location /https {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
63 return 200 $https;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
64 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
65 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
66 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
67
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
68 EOF
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
69
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
70 $t->write_file('openssl.conf', <<EOF);
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
71 [ req ]
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
72 default_bits = 2048
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
73 encrypt_key = no
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
74 distinguished_name = req_distinguished_name
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
75 [ req_distinguished_name ]
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
76 EOF
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
77
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
78 my $d = $t->testdir();
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
79
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
80 foreach my $name ('localhost') {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
81 system('openssl req -x509 -new '
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
82 . "-config '$d/openssl.conf' -subj '/CN=$name/' "
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
83 . "-out '$d/$name.crt' -keyout '$d/$name.key' "
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
84 . ">>$d/openssl.out 2>&1") == 0
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
85 or die "Can't create certificate for $name: $!\n";
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
86 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
87
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
88 open OLDERR, ">&", \*STDERR; close STDERR;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
89 $t->run();
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
90 open STDERR, ">&", \*OLDERR;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
91
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
92 ###############################################################################
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
93
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
94 my ($s, $sid, $frames, $frame);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
95
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
96 # SSL/TLS connection, NPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
97
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
98 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
99 eval { IO::Socket::SSL->can_npn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
100 skip 'OpenSSL NPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
101
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
102 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, npn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
103 $sid = $s->new_stream({ path => '/h2' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
104 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
105
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
106 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
107 is($frame->{data}, 'h2', 'http variable - npn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
108
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
109 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
110
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
111 # SSL/TLS connection, ALPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
112
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
113 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
114 eval { IO::Socket::SSL->can_alpn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
115 skip 'OpenSSL ALPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
116
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
117 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, alpn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
118 $sid = $s->new_stream({ path => '/h2' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
119 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
120
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
121 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
122 is($frame->{data}, 'h2', 'http variable - alpn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
123
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
124 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
125
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
126 # $server_protocol - SSL/TLS connection, NPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
127
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
128 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
129 eval { IO::Socket::SSL->can_npn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
130 skip 'OpenSSL NPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
131
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
132 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, npn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
133 $sid = $s->new_stream({ path => '/sp' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
134 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
135
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
136 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
137 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - npn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
138
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
139 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
140
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
141 # $server_protocol - SSL/TLS connection, ALPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
142
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
143 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
144 eval { IO::Socket::SSL->can_alpn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
145 skip 'OpenSSL ALPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
146
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
147 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, alpn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
148 $sid = $s->new_stream({ path => '/sp' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
149 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
150
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
151 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
152 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - alpn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
153
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
154 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
155
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
156 # $scheme - SSL/TLS connection, NPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
157
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
158 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
159 eval { IO::Socket::SSL->can_npn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
160 skip 'OpenSSL NPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
161
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
162 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, npn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
163 $sid = $s->new_stream({ path => '/scheme' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
164 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
165
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
166 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
167 is($frame->{data}, 'https', 'scheme variable - npn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
168
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
169 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
170
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
171 # $scheme - SSL/TLS connection, ALPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
172
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
173 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
174 eval { IO::Socket::SSL->can_alpn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
175 skip 'OpenSSL ALPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
176
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
177 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, alpn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
178 $sid = $s->new_stream({ path => '/scheme' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
179 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
180
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
181 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
182 is($frame->{data}, 'https', 'scheme variable - alpn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
183
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
184 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
185
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
186 # $https - SSL/TLS connection, NPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
187
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
188 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
189 eval { IO::Socket::SSL->can_npn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
190 skip 'OpenSSL NPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
191
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
192 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, npn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
193 $sid = $s->new_stream({ path => '/https' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
194 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
195
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
196 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
197 is($frame->{data}, 'on', 'https variable - npn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
198
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
199 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
200
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
201 # $https - SSL/TLS connection, ALPN
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
202
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
203 SKIP: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
204 eval { IO::Socket::SSL->can_alpn() or die; };
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
205 skip 'OpenSSL ALPN support required', 1 if $@;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
206
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
207 $s = Test::Nginx::HTTP2->new(8081, SSL => 1, alpn => 'h2');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
208 $sid = $s->new_stream({ path => '/https' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 919
diff changeset
209 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
210
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
211 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
212 is($frame->{data}, 'on', 'https variable - alpn');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
213
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
214 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
215
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
216 ###############################################################################