Mercurial > hg > nginx-tests
comparison mail_smtp_xclient.t @ 970:c227348453db
Tests: simplified parallel modifications in mail tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 08 Jul 2016 02:21:16 +0300 |
parents | e9064d691790 |
children | a8b8dd6e8ae1 |
comparison
equal
deleted
inserted
replaced
969:1edb092149e2 | 970:c227348453db |
---|---|
23 select STDOUT; $| = 1; | 23 select STDOUT; $| = 1; |
24 | 24 |
25 local $SIG{PIPE} = 'IGNORE'; | 25 local $SIG{PIPE} = 'IGNORE'; |
26 | 26 |
27 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(6) | 27 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(6) |
28 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon, port(2)) | 28 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon, port(8026)) |
29 ->write_file_expand('nginx.conf', <<'EOF')->run(); | 29 ->write_file_expand('nginx.conf', <<'EOF')->run(); |
30 | 30 |
31 %%TEST_GLOBALS%% | 31 %%TEST_GLOBALS%% |
32 | 32 |
33 daemon off; | 33 daemon off; |
35 events { | 35 events { |
36 } | 36 } |
37 | 37 |
38 mail { | 38 mail { |
39 proxy_pass_error_message on; | 39 proxy_pass_error_message on; |
40 auth_http http://127.0.0.1:%%PORT_0%%/mail/auth; | 40 auth_http http://127.0.0.1:8080/mail/auth; |
41 xclient on; | 41 xclient on; |
42 | 42 |
43 server { | 43 server { |
44 listen 127.0.0.1:%%PORT_1%%; | 44 listen 127.0.0.1:8025; |
45 protocol smtp; | 45 protocol smtp; |
46 smtp_auth login plain none; | 46 smtp_auth login plain none; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 http { | 50 http { |
51 %%TEST_GLOBALS_HTTP%% | 51 %%TEST_GLOBALS_HTTP%% |
52 | 52 |
53 server { | 53 server { |
54 listen 127.0.0.1:%%PORT_0%%; | 54 listen 127.0.0.1:8080; |
55 server_name localhost; | 55 server_name localhost; |
56 | 56 |
57 location = /mail/auth { | 57 location = /mail/auth { |
58 add_header Auth-Status OK; | 58 add_header Auth-Status OK; |
59 add_header Auth-Server 127.0.0.1; | 59 add_header Auth-Server 127.0.0.1; |
60 add_header Auth-Port %%PORT_2%%; | 60 add_header Auth-Port %%PORT_8026%%; |
61 add_header Auth-Wait 1; | 61 add_header Auth-Wait 1; |
62 return 204; | 62 return 204; |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
80 # | 80 # |
81 # Test them in order. | 81 # Test them in order. |
82 | 82 |
83 # xclient | 83 # xclient |
84 | 84 |
85 my $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1)); | 85 my $s = Test::Nginx::SMTP->new(); |
86 $s->read(); | 86 $s->read(); |
87 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | 87 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
88 $s->authok('xclient'); | 88 $s->authok('xclient'); |
89 | 89 |
90 # xclient, helo | 90 # xclient, helo |
91 | 91 |
92 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1)); | 92 $s = Test::Nginx::SMTP->new(); |
93 $s->read(); | 93 $s->read(); |
94 $s->send('HELO example.com'); | 94 $s->send('HELO example.com'); |
95 $s->read(); | 95 $s->read(); |
96 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | 96 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
97 $s->authok('xclient, helo'); | 97 $s->authok('xclient, helo'); |
98 | 98 |
99 # xclient, ehlo | 99 # xclient, ehlo |
100 | 100 |
101 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1)); | 101 $s = Test::Nginx::SMTP->new(); |
102 $s->read(); | 102 $s->read(); |
103 $s->send('EHLO example.com'); | 103 $s->send('EHLO example.com'); |
104 $s->read(); | 104 $s->read(); |
105 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | 105 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
106 $s->authok('xclient, ehlo'); | 106 $s->authok('xclient, ehlo'); |
107 | 107 |
108 # xclient, from, rcpt | 108 # xclient, from, rcpt |
109 | 109 |
110 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1)); | 110 $s = Test::Nginx::SMTP->new(); |
111 $s->read(); | 111 $s->read(); |
112 $s->send('MAIL FROM:<test@example.com>'); | 112 $s->send('MAIL FROM:<test@example.com>'); |
113 $s->read(); | 113 $s->read(); |
114 $s->send('RCPT TO:<test@example.com>'); | 114 $s->send('RCPT TO:<test@example.com>'); |
115 $s->ok('xclient, from'); | 115 $s->ok('xclient, from'); |
116 | 116 |
117 # xclient, helo, from, rcpt | 117 # xclient, helo, from, rcpt |
118 | 118 |
119 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1)); | 119 $s = Test::Nginx::SMTP->new(); |
120 $s->read(); | 120 $s->read(); |
121 $s->send('HELO example.com'); | 121 $s->send('HELO example.com'); |
122 $s->read(); | 122 $s->read(); |
123 $s->send('MAIL FROM:<test@example.com>'); | 123 $s->send('MAIL FROM:<test@example.com>'); |
124 $s->read(); | 124 $s->read(); |
125 $s->send('RCPT TO:<test@example.com>'); | 125 $s->send('RCPT TO:<test@example.com>'); |
126 $s->ok('xclient, helo, from'); | 126 $s->ok('xclient, helo, from'); |
127 | 127 |
128 # xclient, ehlo, from, rcpt | 128 # xclient, ehlo, from, rcpt |
129 | 129 |
130 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1)); | 130 $s = Test::Nginx::SMTP->new(); |
131 $s->read(); | 131 $s->read(); |
132 $s->send('EHLO example.com'); | 132 $s->send('EHLO example.com'); |
133 $s->read(); | 133 $s->read(); |
134 $s->send('MAIL FROM:<test@example.com>'); | 134 $s->send('MAIL FROM:<test@example.com>'); |
135 $s->read(); | 135 $s->read(); |