Mercurial > hg > nginx-tests
annotate mail_smtp_xclient.t @ 1940:aec72dcee93b
Tests: unconditional QUIC datagram expansion with Initial packets.
Used to get rid of "quic UDP datagram is too small for initial packet" messages.
In future, we may need this to reconsider to allow mocking with custom padding,
but for now suppressing such messages is sufficiently good enough.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 11 Dec 2023 14:01:49 +0400 |
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 ############################################################################### |