Mercurial > hg > nginx-tests
comparison stream_ssl_preread.t @ 1864:46351d990aee
Tests: simplified stream SSL tests with IO::Socket::SSL.
The stream SSL tests which previously used IO::Socket::SSL were converted
to use infrastructure in Test::Nginx::Stream where appropriate.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:15 +0300 |
parents | cdcd75657e52 |
children |
comparison
equal
deleted
inserted
replaced
1863:dbb7561a9441 | 1864:46351d990aee |
---|---|
140 | 140 |
141 # fallback to an empty value for some reason | 141 # fallback to an empty value for some reason |
142 | 142 |
143 is(get_ssl('', 8081), $p3, 'no sni'); | 143 is(get_ssl('', 8081), $p3, 'no sni'); |
144 is(get_ssl('foo', 8082), $p3, 'preread off'); | 144 is(get_ssl('foo', 8082), $p3, 'preread off'); |
145 is(get_ssl('foo', 8083), undef, 'preread buffer full'); | 145 is(get_ssl('foo', 8083), '', 'preread buffer full'); |
146 is(stream('127.0.0.1:' . port(8080))->io('x' x 1000), "127.0.0.1:$p3", | 146 is(stream('127.0.0.1:' . port(8080))->io('x' x 1000), "127.0.0.1:$p3", |
147 'not a handshake'); | 147 'not a handshake'); |
148 | 148 |
149 # ticket #1317 | 149 # ticket #1317 |
150 | 150 |
200 http($r); | 200 http($r); |
201 } | 201 } |
202 | 202 |
203 sub get_ssl { | 203 sub get_ssl { |
204 my ($host, $port) = @_; | 204 my ($host, $port) = @_; |
205 my $s = stream('127.0.0.1:' . port($port)); | 205 |
206 | 206 my $s = stream( |
207 eval { | 207 PeerAddr => '127.0.0.1:' . port($port), |
208 local $SIG{ALRM} = sub { die "timeout\n" }; | 208 SSL => 1, |
209 local $SIG{PIPE} = sub { die "sigpipe\n" }; | 209 SSL_hostname => $host |
210 alarm(8); | 210 ); |
211 IO::Socket::SSL->start_SSL($s->{_socket}, | |
212 SSL_hostname => $host, | |
213 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), | |
214 SSL_error_trap => sub { die $_[1] } | |
215 ); | |
216 alarm(0); | |
217 }; | |
218 alarm(0); | |
219 | |
220 if ($@) { | |
221 log_in("died: $@"); | |
222 return undef; | |
223 } | |
224 | 211 |
225 return $s->read(); | 212 return $s->read(); |
226 } | 213 } |
227 | 214 |
228 ############################################################################### | 215 ############################################################################### |