Mercurial > hg > nginx-tests
comparison mail_smtp_xclient.t @ 148:b714d6df958c
Tests: rename some tests for better sorting.
Use underscore instead of dash. Addtionally, rename some tests to better
match "module" + "details" scheme used: use "http_" prefix for http core
module tests, use "mail_" prefix for mail module tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 04 Mar 2011 16:07:15 +0300 |
parents | smtp-xclient.t@8ac1faaddd2c |
children | 74bc22b97538 |
comparison
equal
deleted
inserted
replaced
147:fd865ada95c8 | 148:b714d6df958c |
---|---|
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 | |
26 local $SIG{PIPE} = 'IGNORE'; | |
27 | |
28 my $t = Test::Nginx->new()->has(qw/mail smtp http/)->plan(6) | |
29 ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) | |
30 ->write_file_expand('nginx.conf', <<'EOF')->run(); | |
31 | |
32 %%TEST_GLOBALS%% | |
33 | |
34 master_process off; | |
35 daemon off; | |
36 | |
37 events { | |
38 } | |
39 | |
40 mail { | |
41 proxy_pass_error_message on; | |
42 auth_http http://127.0.0.1:8080/mail/auth; | |
43 xclient on; | |
44 | |
45 server { | |
46 listen 127.0.0.1:8025; | |
47 protocol smtp; | |
48 smtp_auth login plain none; | |
49 } | |
50 } | |
51 | |
52 http { | |
53 %%TEST_GLOBALS_HTTP%% | |
54 | |
55 server { | |
56 listen 127.0.0.1:8080; | |
57 server_name localhost; | |
58 | |
59 location = /mail/auth { | |
60 add_header Auth-Status OK; | |
61 add_header Auth-Server 127.0.0.1; | |
62 add_header Auth-Port 8026; | |
63 add_header Auth-Wait 1; | |
64 return 204; | |
65 } | |
66 } | |
67 } | |
68 | |
69 EOF | |
70 | |
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 | |
87 my $s = Test::Nginx::SMTP->new(); | |
88 $s->read(); | |
89 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
90 $s->authok('xclient'); | |
91 | |
92 # xclient, helo | |
93 | |
94 $s = Test::Nginx::SMTP->new(); | |
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 | |
103 $s = Test::Nginx::SMTP->new(); | |
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 | |
112 $s = Test::Nginx::SMTP->new(); | |
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 | |
121 $s = Test::Nginx::SMTP->new(); | |
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 | |
132 $s = Test::Nginx::SMTP->new(); | |
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 ############################################################################### |