Mercurial > hg > nginx-tests
comparison mail_ssl.t @ 1148:44620036fedf
Tests: added starttls tests for smtp.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 07 Mar 2017 10:09:29 +0300 |
parents | 796ed08cb215 |
children | 0af58b78df35 |
comparison
equal
deleted
inserted
replaced
1147:796ed08cb215 | 1148:44620036fedf |
---|---|
18 | 18 |
19 use lib 'lib'; | 19 use lib 'lib'; |
20 use Test::Nginx; | 20 use Test::Nginx; |
21 use Test::Nginx::IMAP; | 21 use Test::Nginx::IMAP; |
22 use Test::Nginx::POP3; | 22 use Test::Nginx::POP3; |
23 use Test::Nginx::SMTP; | |
23 | 24 |
24 ############################################################################### | 25 ############################################################################### |
25 | 26 |
26 select STDERR; $| = 1; | 27 select STDERR; $| = 1; |
27 select STDOUT; $| = 1; | 28 select STDOUT; $| = 1; |
32 Net::SSLeay::SSLeay_add_ssl_algorithms(); | 33 Net::SSLeay::SSLeay_add_ssl_algorithms(); |
33 Net::SSLeay::randomize(); | 34 Net::SSLeay::randomize(); |
34 }; | 35 }; |
35 plan(skip_all => 'Net::SSLeay not installed') if $@; | 36 plan(skip_all => 'Net::SSLeay not installed') if $@; |
36 | 37 |
37 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap pop3/) | 38 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap pop3 smtp/) |
38 ->has_daemon('openssl')->plan(16); | 39 ->has_daemon('openssl')->plan(20); |
39 | 40 |
40 $t->write_file_expand('nginx.conf', <<'EOF'); | 41 $t->write_file_expand('nginx.conf', <<'EOF'); |
41 | 42 |
42 %%TEST_GLOBALS%% | 43 %%TEST_GLOBALS%% |
43 | 44 |
113 } | 114 } |
114 | 115 |
115 server { | 116 server { |
116 listen 127.0.0.1:8152; | 117 listen 127.0.0.1:8152; |
117 protocol pop3; | 118 protocol pop3; |
119 | |
120 starttls only; | |
121 } | |
122 | |
123 server { | |
124 listen 127.0.0.1:8153; | |
125 protocol smtp; | |
126 | |
127 starttls on; | |
128 } | |
129 | |
130 server { | |
131 listen 127.0.0.1:8154; | |
132 protocol smtp; | |
118 | 133 |
119 starttls only; | 134 starttls only; |
120 } | 135 } |
121 } | 136 } |
122 | 137 |
244 $s->read(); | 259 $s->read(); |
245 | 260 |
246 $s->send('STLS'); | 261 $s->send('STLS'); |
247 $s->ok('pop3 starttls only'); | 262 $s->ok('pop3 starttls only'); |
248 | 263 |
264 # starttls smtp | |
265 | |
266 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8153)); | |
267 $s->read(); | |
268 | |
269 $s->send('AUTH LOGIN'); | |
270 $s->check(qr/^334 VXNlcm5hbWU6/, 'smtp auth before startls on'); | |
271 | |
272 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8153)); | |
273 $s->read(); | |
274 | |
275 $s->send('STARTTLS'); | |
276 $s->ok('smtp starttls on'); | |
277 | |
278 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8154)); | |
279 $s->read(); | |
280 | |
281 $s->send('AUTH LOGIN'); | |
282 $s->check(qr/^5.. /, 'smtp auth before startls only'); | |
283 | |
284 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8154)); | |
285 $s->read(); | |
286 | |
287 $s->send('STARTTLS'); | |
288 $s->ok('smtp starttls only'); | |
289 | |
249 ############################################################################### | 290 ############################################################################### |
250 | 291 |
251 sub get_ssl_socket { | 292 sub get_ssl_socket { |
252 my ($port, $ses) = @_; | 293 my ($port, $ses) = @_; |
253 my $s; | 294 my $s; |