Mercurial > hg > nginx-tests
annotate mail_smtp_xclient.t @ 1248:70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
The stream js tests introduced in edf5a3c9e36a fail on njs 0.1.14. It doesn't
currently provide an easy way to check its version, whilst we are obligated to
gracefully handle such cases somehow. With such an addition of 'require', now
the tests are skipped instead on the previous versions.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Nov 2017 13:16:39 +0300 |
parents | a8b8dd6e8ae1 |
children | 74986ebee2fd |
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; | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
39 auth_http http://127.0.0.1:8080/mail/auth; |
68 | 40 xclient on; |
41 | |
42 server { | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
43 listen 127.0.0.1:8025; |
68 | 44 protocol smtp; |
45 smtp_auth login plain none; | |
46 } | |
47 } | |
48 | |
49 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
96
diff
changeset
|
50 %%TEST_GLOBALS_HTTP%% |
68 | 51 |
52 server { | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
53 listen 127.0.0.1:8080; |
68 | 54 server_name localhost; |
55 | |
56 location = /mail/auth { | |
57 add_header Auth-Status OK; | |
58 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
|
59 add_header Auth-Port %%PORT_8026%%; |
68 | 60 add_header Auth-Wait 1; |
61 return 204; | |
62 } | |
63 } | |
64 } | |
65 | |
66 EOF | |
67 | |
976
a8b8dd6e8ae1
Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
970
diff
changeset
|
68 $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
|
69 $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
|
70 |
68 | 71 ############################################################################### |
72 | |
73 # When XCLIENT's HELO= argument isn't used, the following combinations may be | |
74 # send to backend with xclient on: | |
75 # | |
76 # xclient | |
77 # xclient, helo | |
78 # xclient, ehlo | |
79 # xclient, from, rcpt | |
80 # xclient, helo, from, rcpt | |
81 # xclient, ehlo, from, rcpt | |
82 # | |
83 # Test them in order. | |
84 | |
85 # xclient | |
86 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
87 my $s = Test::Nginx::SMTP->new(); |
68 | 88 $s->read(); |
89 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
90 $s->authok('xclient'); | |
91 | |
92 # xclient, helo | |
93 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
94 $s = Test::Nginx::SMTP->new(); |
68 | 95 $s->read(); |
96 $s->send('HELO example.com'); | |
97 $s->read(); | |
98 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
99 $s->authok('xclient, helo'); | |
100 | |
101 # xclient, ehlo | |
102 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
103 $s = Test::Nginx::SMTP->new(); |
68 | 104 $s->read(); |
105 $s->send('EHLO example.com'); | |
106 $s->read(); | |
107 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
108 $s->authok('xclient, ehlo'); | |
109 | |
110 # xclient, from, rcpt | |
111 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
112 $s = Test::Nginx::SMTP->new(); |
68 | 113 $s->read(); |
114 $s->send('MAIL FROM:<test@example.com>'); | |
115 $s->read(); | |
116 $s->send('RCPT TO:<test@example.com>'); | |
117 $s->ok('xclient, from'); | |
118 | |
119 # xclient, helo, from, rcpt | |
120 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
121 $s = Test::Nginx::SMTP->new(); |
68 | 122 $s->read(); |
123 $s->send('HELO example.com'); | |
124 $s->read(); | |
125 $s->send('MAIL FROM:<test@example.com>'); | |
126 $s->read(); | |
127 $s->send('RCPT TO:<test@example.com>'); | |
128 $s->ok('xclient, helo, from'); | |
129 | |
130 # xclient, ehlo, from, rcpt | |
131 | |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
132 $s = Test::Nginx::SMTP->new(); |
68 | 133 $s->read(); |
134 $s->send('EHLO example.com'); | |
135 $s->read(); | |
136 $s->send('MAIL FROM:<test@example.com>'); | |
137 $s->read(); | |
138 $s->send('RCPT TO:<test@example.com>'); | |
139 $s->ok('xclient, ehlo, from'); | |
140 | |
141 ############################################################################### |