Mercurial > hg > nginx-tests
comparison mail_smtp.t @ 1109:59d5c8ca7e4d
Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 12 Jan 2017 11:46:11 +0300 |
parents | a8b8dd6e8ae1 |
children | b9b115a2a28d |
comparison
equal
deleted
inserted
replaced
1108:ff1a37f37419 | 1109:59d5c8ca7e4d |
---|---|
25 select STDERR; $| = 1; | 25 select STDERR; $| = 1; |
26 select STDOUT; $| = 1; | 26 select STDOUT; $| = 1; |
27 | 27 |
28 local $SIG{PIPE} = 'IGNORE'; | 28 local $SIG{PIPE} = 'IGNORE'; |
29 | 29 |
30 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(25) | 30 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(27) |
31 ->write_file_expand('nginx.conf', <<'EOF'); | 31 ->write_file_expand('nginx.conf', <<'EOF'); |
32 | 32 |
33 %%TEST_GLOBALS%% | 33 %%TEST_GLOBALS%% |
34 | 34 |
35 daemon off; | 35 daemon off; |
43 xclient off; | 43 xclient off; |
44 | 44 |
45 server { | 45 server { |
46 listen 127.0.0.1:8025; | 46 listen 127.0.0.1:8025; |
47 protocol smtp; | 47 protocol smtp; |
48 smtp_auth login plain none; | 48 smtp_auth login plain none cram-md5; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 http { | 52 http { |
53 %%TEST_GLOBALS_HTTP%% | 53 %%TEST_GLOBALS_HTTP%% |
63 set $reply OK; | 63 set $reply OK; |
64 } | 64 } |
65 | 65 |
66 set $userpass "$http_auth_user:$http_auth_pass"; | 66 set $userpass "$http_auth_user:$http_auth_pass"; |
67 if ($userpass ~ '^test@example.com:secret$') { | 67 if ($userpass ~ '^test@example.com:secret$') { |
68 set $reply OK; | |
69 } | |
70 | |
71 set $userpass "$http_auth_user:$http_auth_salt:$http_auth_pass"; | |
72 if ($userpass ~ '^test@example.com:<.*@.*>:0{32}$') { | |
68 set $reply OK; | 73 set $reply OK; |
69 } | 74 } |
70 | 75 |
71 add_header Auth-Status $reply; | 76 add_header Auth-Status $reply; |
72 add_header Auth-Server 127.0.0.1; | 77 add_header Auth-Server 127.0.0.1; |
137 $s->send('AUTH LOGIN ' . encode_base64('test@example.com', '')); | 142 $s->send('AUTH LOGIN ' . encode_base64('test@example.com', '')); |
138 $s->check(qr/^334 UGFzc3dvcmQ6/, 'auth login with username password challenge'); | 143 $s->check(qr/^334 UGFzc3dvcmQ6/, 'auth login with username password challenge'); |
139 $s->send(encode_base64('secret', '')); | 144 $s->send(encode_base64('secret', '')); |
140 $s->authok('auth login with username'); | 145 $s->authok('auth login with username'); |
141 | 146 |
147 # Try auth cram-md5 | |
148 | |
149 $s = Test::Nginx::SMTP->new(); | |
150 $s->read(); | |
151 $s->send('EHLO example.com'); | |
152 $s->read(); | |
153 | |
154 $s->send('AUTH CRAM-MD5'); | |
155 $s->check(qr/^334 /, 'auth cram-md5 challenge'); | |
156 $s->send(encode_base64('test@example.com ' . ('0' x 32), '')); | |
157 $s->authok('auth cram-md5'); | |
158 | |
142 # Try auth plain with pipelining | 159 # Try auth plain with pipelining |
143 | 160 |
144 $s = Test::Nginx::SMTP->new(); | 161 $s = Test::Nginx::SMTP->new(); |
145 $s->read(); | 162 $s->read(); |
146 $s->send('EHLO example.com'); | 163 $s->send('EHLO example.com'); |