Mercurial > hg > nginx-tests
annotate mail_smtp_xclient.t @ 1829:a78c32419f02
Tests: separate SSL session reuse tests.
Instead of being mixed with generic SSL tests, session reuse variants
are now tested in a separate file.
In the generic SSL tests only basic session reuse is now tested,
notably with session tickets enabled and a shared SSL session cache.
This should make it possible to reuse sessions in all cases (except
when it's not supported, such as with LibreSSL with TLSv1.3).
Note that session reuse with tickets implies that $ssl_session_id
is selected by the client and therefore is not available on the
initial connection. Relevant test is modified to handle this.
Further, BoringSSL does not use legacy session ID with TLSv1.3 even
if it is sent by the client. In contrast, OpenSSL always generates
an unique legacy session id, so it is available with TLSv1.3 even if
session resumption does not work (such as with old Net::SSLeay and
IO::Socket::SSL modules).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 23 Mar 2023 19:49:47 +0300 |
parents | 74986ebee2fd |
children |
rev | line source |
---|---|
68 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 ############################################################################### | |
6 | |
7 use warnings; | |
8 use strict; | |
9 | |
10 use Test::More; | |
11 | |
12 use MIME::Base64; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 use Test::Nginx::SMTP; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
96
ecff5407867c
Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents:
68
diff
changeset
|
25 local $SIG{PIPE} = 'IGNORE'; |
ecff5407867c
Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents:
68
diff
changeset
|
26 |
157
74bc22b97538
Tests: add missing rewrite prerequisite.
Maxim Dounin <mdounin@mdounin.ru>
parents:
148
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(6) |
976
a8b8dd6e8ae1
Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
970
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
68 | 29 |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
30 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
31 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
32 daemon off; |
68 | 33 |
34 events { | |
35 } | |
36 | |
37 mail { | |
38 proxy_pass_error_message on; | |
1679
74986ebee2fd
Tests: added proxy_timeout in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
976
diff
changeset
|
39 proxy_timeout 15s; |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
40 auth_http http://127.0.0.1:8080/mail/auth; |
68 | 41 xclient on; |
42 | |
43 server { | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
44 listen 127.0.0.1:8025; |
68 | 45 protocol smtp; |
46 smtp_auth login plain none; | |
47 } | |
48 } | |
49 | |
50 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
51 %%TEST_GLOBALS_HTTP%% |
68 | 52 |
53 server { | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
54 listen 127.0.0.1:8080; |
68 | 55 server_name localhost; |
56 | |
57 location = /mail/auth { | |
58 add_header Auth-Status OK; | |
59 add_header Auth-Server 127.0.0.1; | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
60 add_header Auth-Port %%PORT_8026%%; |
68 | 61 add_header Auth-Wait 1; |
62 return 204; | |
63 } | |
64 } | |
65 } | |
66 | |
67 EOF | |
68 | |
976
a8b8dd6e8ae1
Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
970
diff
changeset
|
69 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); |
a8b8dd6e8ae1
Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
970
diff
changeset
|
70 $t->run()->waitforsocket('127.0.0.1:' . port(8026)); |
a8b8dd6e8ae1
Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
970
diff
changeset
|
71 |
68 | 72 ############################################################################### |
73 | |
74 # When XCLIENT's HELO= argument isn't used, the following combinations may be | |
75 # send to backend with xclient on: | |
76 # | |
77 # xclient | |
78 # xclient, helo | |
79 # xclient, ehlo | |
80 # xclient, from, rcpt | |
81 # xclient, helo, from, rcpt | |
82 # xclient, ehlo, from, rcpt | |
83 # | |
84 # Test them in order. | |
85 | |
86 # xclient | |
87 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
88 my $s = Test::Nginx::SMTP->new(); |
68 | 89 $s->read(); |
90 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
91 $s->authok('xclient'); | |
92 | |
93 # xclient, helo | |
94 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
95 $s = Test::Nginx::SMTP->new(); |
68 | 96 $s->read(); |
97 $s->send('HELO example.com'); | |
98 $s->read(); | |
99 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
100 $s->authok('xclient, helo'); | |
101 | |
102 # xclient, ehlo | |
103 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
104 $s = Test::Nginx::SMTP->new(); |
68 | 105 $s->read(); |
106 $s->send('EHLO example.com'); | |
107 $s->read(); | |
108 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
109 $s->authok('xclient, ehlo'); | |
110 | |
111 # xclient, from, rcpt | |
112 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
113 $s = Test::Nginx::SMTP->new(); |
68 | 114 $s->read(); |
115 $s->send('MAIL FROM:<test@example.com>'); | |
116 $s->read(); | |
117 $s->send('RCPT TO:<test@example.com>'); | |
118 $s->ok('xclient, from'); | |
119 | |
120 # xclient, helo, from, rcpt | |
121 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
122 $s = Test::Nginx::SMTP->new(); |
68 | 123 $s->read(); |
124 $s->send('HELO example.com'); | |
125 $s->read(); | |
126 $s->send('MAIL FROM:<test@example.com>'); | |
127 $s->read(); | |
128 $s->send('RCPT TO:<test@example.com>'); | |
129 $s->ok('xclient, helo, from'); | |
130 | |
131 # xclient, ehlo, from, rcpt | |
132 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
133 $s = Test::Nginx::SMTP->new(); |
68 | 134 $s->read(); |
135 $s->send('EHLO example.com'); | |
136 $s->read(); | |
137 $s->send('MAIL FROM:<test@example.com>'); | |
138 $s->read(); | |
139 $s->send('RCPT TO:<test@example.com>'); | |
140 $s->ok('xclient, ehlo, from'); | |
141 | |
142 ############################################################################### |