Mercurial > hg > nginx-tests
annotate mail_smtp_xclient.t @ 836:a9c4cebcfe69
Tests: adjusted http resolver test with resend.
Don't bother with socket error to force resolver resend. Nginx doesn't handle
well ECONNREFUSED send() error, which results in "500 Internal Server Error".
It may deserve a separate test, though.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 29 Jan 2016 00:40:05 +0300 |
parents | b86c05516e65 |
children | e9064d691790 |
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) |
68 | 28 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) |
29 ->write_file_expand('nginx.conf', <<'EOF')->run(); | |
30 | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
31 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
32 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
33 daemon off; |
68 | 34 |
35 events { | |
36 } | |
37 | |
38 mail { | |
39 proxy_pass_error_message on; | |
40 auth_http http://127.0.0.1:8080/mail/auth; | |
41 xclient on; | |
42 | |
43 server { | |
44 listen 127.0.0.1:8025; | |
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 { | |
54 listen 127.0.0.1:8080; | |
55 server_name localhost; | |
56 | |
57 location = /mail/auth { | |
58 add_header Auth-Status OK; | |
59 add_header Auth-Server 127.0.0.1; | |
60 add_header Auth-Port 8026; | |
61 add_header Auth-Wait 1; | |
62 return 204; | |
63 } | |
64 } | |
65 } | |
66 | |
67 EOF | |
68 | |
69 ############################################################################### | |
70 | |
71 # When XCLIENT's HELO= argument isn't used, the following combinations may be | |
72 # send to backend with xclient on: | |
73 # | |
74 # xclient | |
75 # xclient, helo | |
76 # xclient, ehlo | |
77 # xclient, from, rcpt | |
78 # xclient, helo, from, rcpt | |
79 # xclient, ehlo, from, rcpt | |
80 # | |
81 # Test them in order. | |
82 | |
83 # xclient | |
84 | |
85 my $s = Test::Nginx::SMTP->new(); | |
86 $s->read(); | |
87 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
88 $s->authok('xclient'); | |
89 | |
90 # xclient, helo | |
91 | |
92 $s = Test::Nginx::SMTP->new(); | |
93 $s->read(); | |
94 $s->send('HELO example.com'); | |
95 $s->read(); | |
96 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
97 $s->authok('xclient, helo'); | |
98 | |
99 # xclient, ehlo | |
100 | |
101 $s = Test::Nginx::SMTP->new(); | |
102 $s->read(); | |
103 $s->send('EHLO example.com'); | |
104 $s->read(); | |
105 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
106 $s->authok('xclient, ehlo'); | |
107 | |
108 # xclient, from, rcpt | |
109 | |
110 $s = Test::Nginx::SMTP->new(); | |
111 $s->read(); | |
112 $s->send('MAIL FROM:<test@example.com>'); | |
113 $s->read(); | |
114 $s->send('RCPT TO:<test@example.com>'); | |
115 $s->ok('xclient, from'); | |
116 | |
117 # xclient, helo, from, rcpt | |
118 | |
119 $s = Test::Nginx::SMTP->new(); | |
120 $s->read(); | |
121 $s->send('HELO example.com'); | |
122 $s->read(); | |
123 $s->send('MAIL FROM:<test@example.com>'); | |
124 $s->read(); | |
125 $s->send('RCPT TO:<test@example.com>'); | |
126 $s->ok('xclient, helo, from'); | |
127 | |
128 # xclient, ehlo, from, rcpt | |
129 | |
130 $s = Test::Nginx::SMTP->new(); | |
131 $s->read(); | |
132 $s->send('EHLO example.com'); | |
133 $s->read(); | |
134 $s->send('MAIL FROM:<test@example.com>'); | |
135 $s->read(); | |
136 $s->send('RCPT TO:<test@example.com>'); | |
137 $s->ok('xclient, ehlo, from'); | |
138 | |
139 ############################################################################### |