Mercurial > hg > nginx-tests
comparison mail_imap_ssl.t @ 1858:cdcd75657e52
Tests: added has_feature() tests for IO::Socket::SSL.
The following distinct features supported:
- "socket_ssl", which requires IO::Socket::SSL and also implies
existance of the IO::Socket::SSL::SSL_VERIFY_NONE() symbol.
It is used by most of the tests.
- "socket_ssl_sni", which requires IO::Socket::SSL with the can_client_sni()
function (1.84), and SNI support available in Net::SSLeay and the OpenSSL
library being used. Used by ssl_sni.t, ssl_sni_sessions.t,
stream_ssl_preread.t. Additional Net::SSLeay testing is believed to be
unneeded and was removed.
- "socket_ssl_alpn", which requires IO::Socket::SSL with ALPN support (2.009),
and ALPN support in Net::SSLeay and the OpenSSL library being used.
Used by h2_ssl.t, h2_ssl_verify_client.t, stream_ssl_alpn.t,
stream_ssl_preread_alpn.t.
- "socket_ssl_sslversion", which requires IO::Socket::SSL with
the get_sslversion() and get_sslversion_int() methods (1.964).
Used by mail_imap_ssl.t.
- "socket_ssl_reused", which requires IO::Socket::SSL with
the get_session_reused() method (2.057). To be used in the following
patches.
This makes it possible to simplify and unify various SSL tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:02 +0300 |
parents | 1522ab9d37b4 |
children | 7681a970f6bd |
comparison
equal
deleted
inserted
replaced
1857:da3889ba0b96 | 1858:cdcd75657e52 |
---|---|
24 ############################################################################### | 24 ############################################################################### |
25 | 25 |
26 select STDERR; $| = 1; | 26 select STDERR; $| = 1; |
27 select STDOUT; $| = 1; | 27 select STDOUT; $| = 1; |
28 | 28 |
29 eval { require IO::Socket::SSL; }; | |
30 plan(skip_all => 'IO::Socket::SSL not installed') if $@; | |
31 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; | |
32 plan(skip_all => 'IO::Socket::SSL too old') if $@; | |
33 | |
34 local $SIG{PIPE} = 'IGNORE'; | 29 local $SIG{PIPE} = 'IGNORE'; |
35 | 30 |
36 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap http rewrite/) | 31 my $t = Test::Nginx->new() |
32 ->has(qw/mail mail_ssl imap http rewrite socket_ssl_sslversion/) | |
37 ->has_daemon('openssl')->plan(13) | 33 ->has_daemon('openssl')->plan(13) |
38 ->write_file_expand('nginx.conf', <<'EOF'); | 34 ->write_file_expand('nginx.conf', <<'EOF'); |
39 | 35 |
40 %%TEST_GLOBALS%% | 36 %%TEST_GLOBALS%% |
41 | 37 |
213 | 209 |
214 # Auth-SSL-Protocol and Auth-SSL-Cipher headers | 210 # Auth-SSL-Protocol and Auth-SSL-Cipher headers |
215 | 211 |
216 my ($cipher, $sslversion); | 212 my ($cipher, $sslversion); |
217 | 213 |
218 if ($IO::Socket::SSL::VERSION >= 1.964) { | 214 $s = get_ssl_socket(8143); |
219 $s = get_ssl_socket(8143); | 215 $cipher = $s->get_cipher(); |
220 $cipher = $s->get_cipher(); | 216 $sslversion = $s->get_sslversion(); |
221 $sslversion = $s->get_sslversion(); | 217 $sslversion =~ s/_/./; |
222 $sslversion =~ s/_/./; | |
223 } | |
224 | 218 |
225 undef $s; | 219 undef $s; |
226 | 220 |
227 # test auth_http request header fields with access_log | 221 # test auth_http request header fields with access_log |
228 | 222 |
237 like($f, qr!^on:SUCCESS:(/?CN=2.example.com):\1:\w+:\w+:[^:]+:s4$!m, | 231 like($f, qr!^on:SUCCESS:(/?CN=2.example.com):\1:\w+:\w+:[^:]+:s4$!m, |
238 'log - good cert'); | 232 'log - good cert'); |
239 like($f, qr!^on:SUCCESS:(/?CN=3.example.com):\1:\w+:\w+:[^:]+:s5$!m, | 233 like($f, qr!^on:SUCCESS:(/?CN=3.example.com):\1:\w+:\w+:[^:]+:s5$!m, |
240 'log - trusted cert'); | 234 'log - trusted cert'); |
241 | 235 |
242 SKIP: { | |
243 skip 'IO::Socket::SSL version >= 1.964 required', 1 | |
244 if $IO::Socket::SSL::VERSION < 1.964; | |
245 | |
246 TODO: { | 236 TODO: { |
247 local $TODO = 'not yet' unless $t->has_version('1.21.2'); | 237 local $TODO = 'not yet' unless $t->has_version('1.21.2'); |
248 | 238 |
249 $f = $t->read_file('auth2.log'); | 239 $f = $t->read_file('auth2.log'); |
250 like($f, qr|^$cipher:$sslversion$|m, 'log - cipher sslversion'); | 240 like($f, qr|^$cipher:$sslversion$|m, 'log - cipher sslversion'); |
251 | |
252 } | |
253 | 241 |
254 } | 242 } |
255 | 243 |
256 ############################################################################### | 244 ############################################################################### |
257 | 245 |