Mercurial > hg > nginx-tests
comparison smtp.t @ 2:33cb557f69d4
Tests: smtp pipelining is here, remove todo flags.
Plus cosmetic autoflush changes and one more test for commands splitted across
many packets.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 03 Sep 2008 02:49:44 +0400 |
parents | c731d50dd6b1 |
children | ce002b2323d3 |
comparison
equal
deleted
inserted
replaced
1:c731d50dd6b1 | 2:33cb557f69d4 |
---|---|
7 ############################################################################### | 7 ############################################################################### |
8 | 8 |
9 use warnings; | 9 use warnings; |
10 use strict; | 10 use strict; |
11 | 11 |
12 use Test::More tests => 25; | 12 use Test::More tests => 26; |
13 | 13 |
14 use IO::Socket; | 14 use IO::Socket; |
15 use MIME::Base64; | 15 use MIME::Base64; |
16 | 16 |
17 use constant CRLF => "\x0D\x0A"; | 17 use constant CRLF => "\x0D\x0A"; |
18 | 18 |
19 $| = 1; | 19 select STDERR; $| = 1; |
20 select STDOUT; $| = 1; | |
20 | 21 |
21 my $s = smtp_connect(); | 22 my $s = smtp_connect(); |
22 smtp_check(qr/^220 /, "greeting"); | 23 smtp_check(qr/^220 /, "greeting"); |
23 | 24 |
24 smtp_send('EHLO example.com'); | 25 smtp_send('EHLO example.com'); |
50 smtp_check(qr/^220 /, "greeting"); | 51 smtp_check(qr/^220 /, "greeting"); |
51 | 52 |
52 smtp_send('EHLO example.com'); | 53 smtp_send('EHLO example.com'); |
53 smtp_check(qr/^250 /, "ehlo"); | 54 smtp_check(qr/^250 /, "ehlo"); |
54 | 55 |
55 TODO: { | 56 smtp_send('INVALID COMMAND WITH ARGUMENTS' . CRLF |
56 local $TODO = "pipelining not implemented yet"; | 57 . 'RSET'); |
58 smtp_read(); | |
59 smtp_ok('pipelined rset after invalid command'); | |
57 | 60 |
58 smtp_send('INVALID COMMAND WITH ARGUMENTS' . CRLF | 61 smtp_send('AUTH PLAIN ' |
59 . 'RSET'); | 62 . encode_base64("test\@example.com\0\0bad", '') . CRLF |
60 smtp_read(); | 63 . 'MAIL FROM:<test@example.com> SIZE=100'); |
61 smtp_ok('rset after invalid command'); | 64 smtp_read(); |
65 smtp_ok('mail from after failed pipelined auth'); | |
62 | 66 |
63 smtp_send('AUTH PLAIN ' | 67 smtp_send('AUTH PLAIN ' |
64 . encode_base64("test\@example.com\0\0bad", '') . CRLF | 68 . encode_base64("test\@example.com\0\0secret", '') . CRLF |
65 . 'MAIL FROM:<test@example.com> SIZE=100'); | 69 . 'MAIL FROM:<test@example.com> SIZE=100'); |
66 smtp_read(); | 70 smtp_read(); |
67 smtp_ok('mail from after failed pipelined auth'); | 71 smtp_ok('mail from after pipelined auth'); |
68 | |
69 smtp_send('AUTH PLAIN ' | |
70 . encode_base64("test\@example.com\0\0secret", '') . CRLF | |
71 . 'MAIL FROM:<test@example.com> SIZE=100'); | |
72 smtp_read(); | |
73 smtp_ok('mail from after pipelined auth'); | |
74 } | |
75 | 72 |
76 # Try auth none | 73 # Try auth none |
77 | 74 |
78 $s = smtp_connect(); | 75 $s = smtp_connect(); |
79 smtp_check(qr/^220 /, "greeting"); | 76 smtp_check(qr/^220 /, "greeting"); |
96 smtp_check(qr/^220 /, "greeting"); | 93 smtp_check(qr/^220 /, "greeting"); |
97 | 94 |
98 smtp_send('EHLO example.com'); | 95 smtp_send('EHLO example.com'); |
99 smtp_check(qr/^250 /, "ehlo"); | 96 smtp_check(qr/^250 /, "ehlo"); |
100 | 97 |
101 TODO: { | 98 smtp_send('MAIL FROM:<test@example.com> SIZE=100' . CRLF |
102 smtp_send('MAIL FROM:<test@example.com> SIZE=100' . CRLF | 99 . 'RCPT TO:<test@example.com>' . CRLF |
103 . 'RCPT TO:<test@example.com>' . CRLF | 100 . 'RSET'); |
104 . 'RSET'); | |
105 | 101 |
106 smtp_ok('pipelined mail from'); | 102 smtp_ok('pipelined mail from'); |
107 | 103 |
108 local $TODO = "pipelining not implemented yet"; | 104 smtp_ok('pipelined rcpt to'); |
109 | 105 smtp_ok('pipelined rset'); |
110 smtp_ok('pipelined rcpt to'); | |
111 smtp_ok('pipelined rset'); | |
112 } | |
113 | 106 |
114 # Connection must stay even if error returned to rcpt to command | 107 # Connection must stay even if error returned to rcpt to command |
115 | 108 |
116 $s = smtp_connect(); | 109 $s = smtp_connect(); |
117 smtp_read(); # skip greeting | 110 smtp_read(); # skip greeting |
126 smtp_check(qr/^5.. /, "bad rcpt to"); | 119 smtp_check(qr/^5.. /, "bad rcpt to"); |
127 | 120 |
128 smtp_send('RCPT TO:<test@example.com>'); | 121 smtp_send('RCPT TO:<test@example.com>'); |
129 smtp_ok('good rcpt to'); | 122 smtp_ok('good rcpt to'); |
130 | 123 |
124 # Make sure command splitted into many packets processed correctly | |
125 | |
126 $s = smtp_connect(); | |
127 smtp_read(); | |
128 | |
129 log_out('HEL'); | |
130 $s->print('HEL'); | |
131 smtp_send('O example.com'); | |
132 smtp_ok('splitted command'); | |
131 | 133 |
132 ############################################################################### | 134 ############################################################################### |
133 | 135 |
134 sub log_out { | 136 sub log_out { |
135 my ($msg) = @_; | 137 my ($msg) = @_; |