Mercurial > hg > nginx-tests
annotate smtp-xclient.t @ 100:9ddc18214854
Tests: arbitrary regexp support in has().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 01 Oct 2009 14:28:08 +0400 |
parents | ecff5407867c |
children | 1c0ec30614c6 |
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 |
68 | 28 my $t = Test::Nginx->new()->has('mail')->plan(6) |
29 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) | |
30 ->write_file_expand('nginx.conf', <<'EOF')->run(); | |
31 | |
32 master_process off; | |
33 daemon off; | |
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 { | |
51 access_log off; | |
52 | |
53 client_body_temp_path %%TESTDIR%%/client_body_temp; | |
54 fastcgi_temp_path %%TESTDIR%%/fastcgi_temp; | |
55 proxy_temp_path %%TESTDIR%%/proxy_temp; | |
56 | |
57 server { | |
58 listen 127.0.0.1:8080; | |
59 server_name localhost; | |
60 | |
61 location = /mail/auth { | |
62 add_header Auth-Status OK; | |
63 add_header Auth-Server 127.0.0.1; | |
64 add_header Auth-Port 8026; | |
65 add_header Auth-Wait 1; | |
66 return 204; | |
67 } | |
68 } | |
69 } | |
70 | |
71 EOF | |
72 | |
73 ############################################################################### | |
74 | |
75 # When XCLIENT's HELO= argument isn't used, the following combinations may be | |
76 # send to backend with xclient on: | |
77 # | |
78 # xclient | |
79 # xclient, helo | |
80 # xclient, ehlo | |
81 # xclient, from, rcpt | |
82 # xclient, helo, from, rcpt | |
83 # xclient, ehlo, from, rcpt | |
84 # | |
85 # Test them in order. | |
86 | |
87 # xclient | |
88 | |
89 my $s = Test::Nginx::SMTP->new(); | |
90 $s->read(); | |
91 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
92 $s->authok('xclient'); | |
93 | |
94 # xclient, helo | |
95 | |
96 $s = Test::Nginx::SMTP->new(); | |
97 $s->read(); | |
98 $s->send('HELO example.com'); | |
99 $s->read(); | |
100 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
101 $s->authok('xclient, helo'); | |
102 | |
103 # xclient, ehlo | |
104 | |
105 $s = Test::Nginx::SMTP->new(); | |
106 $s->read(); | |
107 $s->send('EHLO example.com'); | |
108 $s->read(); | |
109 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
110 $s->authok('xclient, ehlo'); | |
111 | |
112 # xclient, from, rcpt | |
113 | |
114 $s = Test::Nginx::SMTP->new(); | |
115 $s->read(); | |
116 $s->send('MAIL FROM:<test@example.com>'); | |
117 $s->read(); | |
118 $s->send('RCPT TO:<test@example.com>'); | |
119 $s->ok('xclient, from'); | |
120 | |
121 # xclient, helo, from, rcpt | |
122 | |
123 $s = Test::Nginx::SMTP->new(); | |
124 $s->read(); | |
125 $s->send('HELO example.com'); | |
126 $s->read(); | |
127 $s->send('MAIL FROM:<test@example.com>'); | |
128 $s->read(); | |
129 $s->send('RCPT TO:<test@example.com>'); | |
130 $s->ok('xclient, helo, from'); | |
131 | |
132 # xclient, ehlo, from, rcpt | |
133 | |
134 $s = Test::Nginx::SMTP->new(); | |
135 $s->read(); | |
136 $s->send('EHLO example.com'); | |
137 $s->read(); | |
138 $s->send('MAIL FROM:<test@example.com>'); | |
139 $s->read(); | |
140 $s->send('RCPT TO:<test@example.com>'); | |
141 $s->ok('xclient, ehlo, from'); | |
142 | |
143 ############################################################################### |