# HG changeset patch # User Maxim Dounin # Date 1231695805 -10800 # Node ID d053b4bf6ec625ecf43b64e09fb949801e11c400 # Parent b5b4271554b01ad35a80f0cdaad3466869c87dff Tests: add smtp auth login tests. This covers both simple auth login and (not yet supported) auth login with user name. diff --git a/smtp.t b/smtp.t --- a/smtp.t +++ b/smtp.t @@ -26,7 +26,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new() - ->has('mail')->plan(20) + ->has('mail')->plan(25) ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) ->write_file_expand('nginx.conf', <<'EOF')->run(); @@ -111,6 +111,40 @@ my $s = Test::Nginx::SMTP->new(); $s->send('QUIT'); $s->ok("quit"); +# Try auth login in simple form + +$s = Test::Nginx::SMTP->new(); +$s->read(); +$s->send('EHLO example.com'); +$s->read(); + +$s->send('AUTH LOGIN'); +$s->check(qr/^334 VXNlcm5hbWU6/, 'auth login simple username challenge'); +$s->send(encode_base64('test@example.com', '')); +$s->check(qr/^334 UGFzc3dvcmQ6/, 'auth login simple password challenge'); +$s->send(encode_base64('secret', '')); +$s->ok('auth login simple'); + +# Try auth plain with username. Details: +# +# [MS-XLOGIN]: SMTP Protocol AUTH LOGIN Extension Specification +# http://download.microsoft.com/download/5/D/D/5DD33FDF-91F5-496D-9884-0A0B0EE698BB/%5BMS-XLOGIN%5D.pdf + +TODO: { +local $TODO = 'not supported yet'; + +$s = Test::Nginx::SMTP->new(); +$s->read(); +$s->send('EHLO example.com'); +$s->read(); + +$s->send('AUTH LOGIN ' . encode_base64('test@example.com', '')); +$s->check(qr/^334 UGFzc3dvcmQ6/, 'auth login with username password challenge'); +$s->send(encode_base64('secret', '')); +$s->ok('auth login with username'); + +} + # Try auth plain with pipelining TODO: {