Mercurial > hg > nginx-tests
diff 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 |
line wrap: on
line diff
--- a/mail_smtp.t Tue Jan 10 14:56:57 2017 +0300 +++ b/mail_smtp.t Thu Jan 12 11:46:11 2017 +0300 @@ -27,7 +27,7 @@ local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(25) +my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(27) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -45,7 +45,7 @@ server { listen 127.0.0.1:8025; protocol smtp; - smtp_auth login plain none; + smtp_auth login plain none cram-md5; } } @@ -68,6 +68,11 @@ set $reply OK; } + set $userpass "$http_auth_user:$http_auth_salt:$http_auth_pass"; + if ($userpass ~ '^test@example.com:<.*@.*>:0{32}$') { + set $reply OK; + } + add_header Auth-Status $reply; add_header Auth-Server 127.0.0.1; add_header Auth-Port %%PORT_8026%%; @@ -139,6 +144,18 @@ $s->send(encode_base64('secret', '')); $s->authok('auth login with username'); +# Try auth cram-md5 + +$s = Test::Nginx::SMTP->new(); +$s->read(); +$s->send('EHLO example.com'); +$s->read(); + +$s->send('AUTH CRAM-MD5'); +$s->check(qr/^334 /, 'auth cram-md5 challenge'); +$s->send(encode_base64('test@example.com ' . ('0' x 32), '')); +$s->authok('auth cram-md5'); + # Try auth plain with pipelining $s = Test::Nginx::SMTP->new();