Mercurial > hg > nginx-tests
annotate mail_smtp_xclient.t @ 431:05c46688b54b
Tests: ssl_password_file.t fixes.
Make sure to always specify listen socket in all servers as the
default vary (under root, nginx will try to listen on 80). Make sure
to detect if an https request was processed by http.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 09 Jul 2014 05:19:51 +0400 |
parents | 6a0d934950bc |
children | b86c05516e65 |
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 use Socket qw/ CRLF /; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::SMTP; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
96
ecff5407867c
Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents:
68
diff
changeset
|
26 local $SIG{PIPE} = 'IGNORE'; |
ecff5407867c
Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents:
68
diff
changeset
|
27 |
157
74bc22b97538
Tests: add missing rewrite prerequisite.
Maxim Dounin <mdounin@mdounin.ru>
parents:
148
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(6) |
68 | 29 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) |
30 ->write_file_expand('nginx.conf', <<'EOF')->run(); | |
31 | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
32 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
33 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
34 daemon off; |
68 | 35 |
36 events { | |
37 } | |
38 | |
39 mail { | |
40 proxy_pass_error_message on; | |
41 auth_http http://127.0.0.1:8080/mail/auth; | |
42 xclient on; | |
43 | |
44 server { | |
45 listen 127.0.0.1:8025; | |
46 protocol smtp; | |
47 smtp_auth login plain none; | |
48 } | |
49 } | |
50 | |
51 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
52 %%TEST_GLOBALS_HTTP%% |
68 | 53 |
54 server { | |
55 listen 127.0.0.1:8080; | |
56 server_name localhost; | |
57 | |
58 location = /mail/auth { | |
59 add_header Auth-Status OK; | |
60 add_header Auth-Server 127.0.0.1; | |
61 add_header Auth-Port 8026; | |
62 add_header Auth-Wait 1; | |
63 return 204; | |
64 } | |
65 } | |
66 } | |
67 | |
68 EOF | |
69 | |
70 ############################################################################### | |
71 | |
72 # When XCLIENT's HELO= argument isn't used, the following combinations may be | |
73 # send to backend with xclient on: | |
74 # | |
75 # xclient | |
76 # xclient, helo | |
77 # xclient, ehlo | |
78 # xclient, from, rcpt | |
79 # xclient, helo, from, rcpt | |
80 # xclient, ehlo, from, rcpt | |
81 # | |
82 # Test them in order. | |
83 | |
84 # xclient | |
85 | |
86 my $s = Test::Nginx::SMTP->new(); | |
87 $s->read(); | |
88 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
89 $s->authok('xclient'); | |
90 | |
91 # xclient, helo | |
92 | |
93 $s = Test::Nginx::SMTP->new(); | |
94 $s->read(); | |
95 $s->send('HELO example.com'); | |
96 $s->read(); | |
97 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
98 $s->authok('xclient, helo'); | |
99 | |
100 # xclient, ehlo | |
101 | |
102 $s = Test::Nginx::SMTP->new(); | |
103 $s->read(); | |
104 $s->send('EHLO example.com'); | |
105 $s->read(); | |
106 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
107 $s->authok('xclient, ehlo'); | |
108 | |
109 # xclient, from, rcpt | |
110 | |
111 $s = Test::Nginx::SMTP->new(); | |
112 $s->read(); | |
113 $s->send('MAIL FROM:<test@example.com>'); | |
114 $s->read(); | |
115 $s->send('RCPT TO:<test@example.com>'); | |
116 $s->ok('xclient, from'); | |
117 | |
118 # xclient, helo, from, rcpt | |
119 | |
120 $s = Test::Nginx::SMTP->new(); | |
121 $s->read(); | |
122 $s->send('HELO example.com'); | |
123 $s->read(); | |
124 $s->send('MAIL FROM:<test@example.com>'); | |
125 $s->read(); | |
126 $s->send('RCPT TO:<test@example.com>'); | |
127 $s->ok('xclient, helo, from'); | |
128 | |
129 # xclient, ehlo, from, rcpt | |
130 | |
131 $s = Test::Nginx::SMTP->new(); | |
132 $s->read(); | |
133 $s->send('EHLO example.com'); | |
134 $s->read(); | |
135 $s->send('MAIL FROM:<test@example.com>'); | |
136 $s->read(); | |
137 $s->send('RCPT TO:<test@example.com>'); | |
138 $s->ok('xclient, ehlo, from'); | |
139 | |
140 ############################################################################### |