comparison smtp.t @ 3:ce002b2323d3

Tests: test for smtp_greeting_delay.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 03 Sep 2008 23:22:06 +0400
parents 33cb557f69d4
children 6c41dbb2954f
comparison
equal deleted inserted replaced
2:33cb557f69d4 3:ce002b2323d3
128 128
129 log_out('HEL'); 129 log_out('HEL');
130 $s->print('HEL'); 130 $s->print('HEL');
131 smtp_send('O example.com'); 131 smtp_send('O example.com');
132 smtp_ok('splitted command'); 132 smtp_ok('splitted command');
133
134 # With smtp_greeting_delay session expected to be closed after first error
135 # message if client sent something before greeting. Use 10026 port
136 # configured with smtp_greeting_delay 0.1s to check this.
137
138 $s = smtp_connect(PeerPort => 10026);
139 smtp_send('HELO example.com');
140 smtp_check(qr/^5.. /, "command before greeting - session must be rejected");
141 ok($s->eof(), "session have to be closed");
133 142
134 ############################################################################### 143 ###############################################################################
135 144
136 sub log_out { 145 sub log_out {
137 my ($msg) = @_; 146 my ($msg) = @_;
150 sub smtp_connect { 159 sub smtp_connect {
151 my $s = IO::Socket::INET->new( 160 my $s = IO::Socket::INET->new(
152 Proto => "tcp", 161 Proto => "tcp",
153 PeerAddr => "localhost", 162 PeerAddr => "localhost",
154 PeerPort => 10025, 163 PeerPort => 10025,
164 @_
155 ) 165 )
156 or die "Can't connect to nginx: $!\n"; 166 or die "Can't connect to nginx: $!\n";
157 167
158 $s->autoflush(1); 168 $s->autoflush(1);
159 169