Mercurial > hg > nginx-tests
diff mail_imap.t @ 1685:869b312c214e
Tests: additional IMAP tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 May 2021 04:33:11 +0300 |
parents | e6bf510f5e13 |
children | 156cb84b3c23 |
line wrap: on
line diff
--- a/mail_imap.t Wed May 19 04:33:09 2021 +0300 +++ b/mail_imap.t Wed May 19 04:33:11 2021 +0300 @@ -12,6 +12,7 @@ use Test::More; use MIME::Base64; +use Socket qw/ CRLF /; BEGIN { use FindBin; chdir($FindBin::Bin); } @@ -60,7 +61,10 @@ set $passw ""; set $userpass "$http_auth_user:$http_auth_pass"; - if ($userpass ~ '^test@example.com:secret$') { + if ($userpass = 'test@example.com:secret') { + set $reply OK; + } + if ($userpass = 'te\\"st@example.com:se\\"cret') { set $reply OK; } @@ -71,7 +75,7 @@ } set $userpass "$http_auth_method:$http_auth_user:$http_auth_pass"; - if ($userpass ~ '^external:test@example.com:$') { + if ($userpass = 'external:test@example.com:') { set $reply OK; set $passw secret; } @@ -89,16 +93,30 @@ EOF $t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon); -$t->run()->plan(14); +$t->run()->plan(23); $t->waitforsocket('127.0.0.1:' . port(8144)); ############################################################################### +# login + my $s = Test::Nginx::IMAP->new(); $s->ok('greeting'); -# bad auth +$s->send('a01 LOGIN'); +$s->check(qr/^a01 BAD/, 'login without arguments'); + +$s->send('a02 LOGIN test@example.com bad'); +$s->check(qr/^a02 NO/, 'login with bad password'); + +$s->send('a03 LOGIN test@example.com secret'); +$s->ok('login'); + +# auth + +$s = Test::Nginx::IMAP->new(); +$s->read(); $s->send('1 AUTHENTICATE'); $s->check(qr/^\S+ BAD/, 'auth without arguments'); @@ -166,4 +184,51 @@ $s->send('1 AUTHENTICATE EXTERNAL ' . encode_base64('test@example.com', '')); $s->ok('auth external with username'); +# quoted strings + +$s = Test::Nginx::IMAP->new(); +$s->read(); + +$s->send('a01 LOGIN "te\\\\\"st@example.com" "se\\\\\"cret"'); +$s->ok('quoted strings'); + +# literals + +$s = Test::Nginx::IMAP->new(); +$s->read(); + +$s->send('a01 LOGIN {18}'); +$s->check(qr/\+ /, 'login username literal continue'); + +$s->send('te\"st@example.com' . ' {8}'); +$s->check(qr/\+ /, 'login password literal continue'); + +$s->send('se\"cret'); +$s->ok('login literals'); + +# non-synchronizing literals + +$s = Test::Nginx::IMAP->new(); +$s->read(); + +$s->send('a01 LOGIN {18+}' . CRLF + . 'te\"st@example.com' . ' {8+}' . CRLF + . 'se\"cret'); +$s->ok('login non-sync literals'); + +# backslash in quotes and literals + +$s = Test::Nginx::IMAP->new(); +$s->read(); + +$s->send('a01 LOGIN {18+}' . CRLF + . 'te\"st@example.com' . ' "se\\\\\"cret"'); + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.21.0'); + +$s->ok('backslash in literal'); + +} + ###############################################################################