blob: eccc9c22deffcbb01c23752d06e1fab7218830d7 [file] [log] [blame]
Maxim Dounin96a65a72008-09-13 03:37:45 +04001#!/usr/bin/perl
2
3# (C) Maxim Dounin
4
5###############################################################################
6
7use warnings;
8use strict;
9
Maxim Dounine0a4a1b2008-10-10 20:09:14 +040010use Test::More;
Maxim Dounin96a65a72008-09-13 03:37:45 +040011
Maxim Dounin96a65a72008-09-13 03:37:45 +040012BEGIN { use FindBin; chdir($FindBin::Bin); }
13
14use lib 'lib';
15use Test::Nginx;
16use Test::Nginx::SMTP;
17
18###############################################################################
19
20select STDERR; $| = 1;
21select STDOUT; $| = 1;
22
Maxim Dounin09263aa2008-10-10 20:23:39 +040023my $t = Test::Nginx->new()->has('mail')->plan(2)
Maxim Dounine0a4a1b2008-10-10 20:09:14 +040024 ->write_file_expand('nginx.conf', <<'EOF')->run();
Maxim Dounin96a65a72008-09-13 03:37:45 +040025
26master_process off;
27daemon off;
28
29events {
30 worker_connections 1024;
31}
32
33mail {
34 proxy_pass_error_message on;
35 auth_http http://localhost:8080/mail/auth;
36 xclient off;
37
38 server {
Maxim Douninaa7461b2008-10-02 16:18:11 +040039 listen localhost:8025;
Maxim Dounin96a65a72008-09-13 03:37:45 +040040 protocol smtp;
41 smtp_greeting_delay 100ms;
42 }
43}
44
45EOF
46
47###############################################################################
48
49# With smtp_greeting_delay session expected to be closed after first error
50# message if client sent something before greeting.
51
52my $s = Test::Nginx::SMTP->new();
53$s->send('HELO example.com');
54$s->check(qr/^5.. /, "command before greeting - session must be rejected");
55ok($s->eof(), "session have to be closed");
56
57###############################################################################