Mercurial > hg > nginx-tests
comparison smtp.t @ 56:573c8293ac38
Tests: fix smtp auth plain tests to check username.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 11 Jan 2009 19:53:36 +0300 |
parents | d68b85def521 |
children | b5b4271554b0 |
comparison
equal
deleted
inserted
replaced
55:2020bf9c75ce | 56:573c8293ac38 |
---|---|
64 set $reply ERROR; | 64 set $reply ERROR; |
65 | 65 |
66 if ($http_auth_smtp_to ~ example.com) { | 66 if ($http_auth_smtp_to ~ example.com) { |
67 set $reply OK; | 67 set $reply OK; |
68 } | 68 } |
69 if ($http_auth_pass ~ secret) { | 69 |
70 set $userpass "$http_auth_user:$http_auth_pass"; | |
71 if ($userpass ~ '^test@example.com:secret$') { | |
70 set $reply OK; | 72 set $reply OK; |
71 } | 73 } |
72 | 74 |
73 add_header Auth-Status $reply; | 75 add_header Auth-Status $reply; |
74 add_header Auth-Server 127.0.0.1; | 76 add_header Auth-Server 127.0.0.1; |
87 $s->check(qr/^220 /, "greeting"); | 89 $s->check(qr/^220 /, "greeting"); |
88 | 90 |
89 $s->send('EHLO example.com'); | 91 $s->send('EHLO example.com'); |
90 $s->check(qr/^250 /, "ehlo"); | 92 $s->check(qr/^250 /, "ehlo"); |
91 | 93 |
92 $s->send('AUTH PLAIN ' . encode_base64("test\@example.com\0\0bad", '')); | 94 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0bad", '')); |
93 $s->check(qr/^5.. /, 'auth plain with bad password'); | 95 $s->check(qr/^5.. /, 'auth plain with bad password'); |
94 | 96 |
95 $s->send('AUTH PLAIN ' . encode_base64("test\@example.com\0\0secret", '')); | 97 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
96 $s->ok('auth plain'); | 98 $s->ok('auth plain'); |
97 | 99 |
98 # We are talking to backend from this point | 100 # We are talking to backend from this point |
99 | 101 |
100 $s->send('MAIL FROM:<test@example.com> SIZE=100'); | 102 $s->send('MAIL FROM:<test@example.com> SIZE=100'); |
121 . 'RSET'); | 123 . 'RSET'); |
122 $s->read(); | 124 $s->read(); |
123 $s->ok('pipelined rset after invalid command'); | 125 $s->ok('pipelined rset after invalid command'); |
124 | 126 |
125 $s->send('AUTH PLAIN ' | 127 $s->send('AUTH PLAIN ' |
126 . encode_base64("test\@example.com\0\0bad", '') . CRLF | 128 . encode_base64("\0test\@example.com\0bad", '') . CRLF |
127 . 'MAIL FROM:<test@example.com> SIZE=100'); | 129 . 'MAIL FROM:<test@example.com> SIZE=100'); |
128 $s->read(); | 130 $s->read(); |
129 $s->ok('mail from after failed pipelined auth'); | 131 $s->ok('mail from after failed pipelined auth'); |
130 | 132 |
131 $s->send('AUTH PLAIN ' | 133 $s->send('AUTH PLAIN ' |
132 . encode_base64("test\@example.com\0\0secret", '') . CRLF | 134 . encode_base64("\0test\@example.com\0secret", '') . CRLF |
133 . 'MAIL FROM:<test@example.com> SIZE=100'); | 135 . 'MAIL FROM:<test@example.com> SIZE=100'); |
134 $s->read(); | 136 $s->read(); |
135 $s->ok('mail from after pipelined auth'); | 137 $s->ok('mail from after pipelined auth'); |
136 | 138 |
137 # Try auth none | 139 # Try auth none |