comparison mail_smtp_xclient.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents b86c05516e65
children c227348453db
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
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) 28 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon, port(2))
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:8080/mail/auth; 40 auth_http http://127.0.0.1:%%PORT_0%%/mail/auth;
41 xclient on; 41 xclient on;
42 42
43 server { 43 server {
44 listen 127.0.0.1:8025; 44 listen 127.0.0.1:%%PORT_1%%;
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:8080; 54 listen 127.0.0.1:%%PORT_0%%;
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 8026; 60 add_header Auth-Port %%PORT_2%%;
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(); 85 my $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1));
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(); 92 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1));
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(); 101 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1));
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(); 110 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1));
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(); 119 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1));
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(); 130 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(1));
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();