comparison h2_ssl.t @ 1033:45c80276d691

Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 14 Sep 2016 19:38:13 +0300
parents 3c5d3b384d3f
children a034903de974
comparison
equal deleted inserted replaced
1032:43eedbfea090 1033:45c80276d691
25 25
26 eval { require IO::Socket::SSL; }; 26 eval { require IO::Socket::SSL; };
27 plan(skip_all => 'IO::Socket::SSL not installed') if $@; 27 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
28 28
29 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2/) 29 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2/)
30 ->has_daemon('openssl')->plan(1); 30 ->has_daemon('openssl');
31
32 $t->todo_alerts() unless $t->has_version('1.11.3');
31 33
32 $t->write_file_expand('nginx.conf', <<'EOF'); 34 $t->write_file_expand('nginx.conf', <<'EOF');
33 35
34 %%TEST_GLOBALS%% 36 %%TEST_GLOBALS%%
35 37
77 79
78 open OLDERR, ">&", \*STDERR; close STDERR; 80 open OLDERR, ">&", \*STDERR; close STDERR;
79 $t->run(); 81 $t->run();
80 open STDERR, ">&", \*OLDERR; 82 open STDERR, ">&", \*OLDERR;
81 83
84 plan(skip_all => 'no ALPN/NPN negotiation') unless defined getconn(port(0));
85 $t->plan(1);
86
82 ############################################################################### 87 ###############################################################################
83 88
84 # client cancels 2nd stream after HEADERS has been created 89 # client cancels 2nd stream after HEADERS has been created
85 # while some unsent data was left in the SSL buffer 90 # while some unsent data was left in the SSL buffer
86 # HEADERS frame may stuck in SSL buffer and won't be sent producing alert 91 # HEADERS frame may stuck in SSL buffer and won't be sent producing alert
87 92
88 SKIP: {
89 my $s = getconn(port(0)); 93 my $s = getconn(port(0));
90 skip 'OpenSSL ALPN/NPN support required', 1 unless defined $s;
91
92 ok($s, 'ssl connection'); 94 ok($s, 'ssl connection');
93
94 $t->todo_alerts() unless $t->has_version('1.11.3');
95 95
96 my $sid = $s->new_stream({ path => '/tbig.html' }); 96 my $sid = $s->new_stream({ path => '/tbig.html' });
97 97
98 select undef, undef, undef, 0.2; 98 select undef, undef, undef, 0.2;
99 $s->h2_rst($sid, 8); 99 $s->h2_rst($sid, 8);
103 select undef, undef, undef, 0.2; 103 select undef, undef, undef, 0.2;
104 $s->h2_rst($sid, 8); 104 $s->h2_rst($sid, 8);
105 105
106 $t->stop(); 106 $t->stop();
107 107
108 }
109
110 ############################################################################### 108 ###############################################################################
111 109
112 sub getconn { 110 sub getconn {
113 my ($port) = @_; 111 my ($port) = @_;
114 my $s; 112 my $s;
115 113
116 eval { 114 eval {
117 IO::Socket::SSL->can_alpn() or die; 115 my $sock = Test::Nginx::HTTP2::new_socket($port, SSL => 1,
118 $s = Test::Nginx::HTTP2->new($port, SSL => 1, alpn => 'h2'); 116 alpn => 'h2');
117 $s = Test::Nginx::HTTP2->new($port, socket => $sock)
118 if $sock->alpn_selected();
119 }; 119 };
120 120
121 return $s if defined $s; 121 return $s if defined $s;
122 122
123 eval { 123 eval {
124 IO::Socket::SSL->can_npn() or die; 124 my $sock = Test::Nginx::HTTP2::new_socket($port, SSL => 1,
125 $s = Test::Nginx::HTTP2->new($port, SSL => 1, npn => 'h2'); 125 npn => 'h2');
126 $s = Test::Nginx::HTTP2->new($port, socket => $sock)
127 if $sock->next_proto_negotiated();
126 }; 128 };
127 129
128 return $s; 130 return $s;
129 } 131 }
130 132