blob: ad49f2d90f92e439c1285839eec60eff5ccd1b0f [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 Douninf9b2aad2011-07-26 15:04:01 +040023local $SIG{PIPE} = 'IGNORE';
24
Maxim Douninff9b36a2009-12-26 16:06:17 +030025my $t = Test::Nginx->new()->has(qw/mail smtp http/)->plan(2)
Maxim Dounine0a4a1b2008-10-10 20:09:14 +040026 ->write_file_expand('nginx.conf', <<'EOF')->run();
Maxim Dounin96a65a72008-09-13 03:37:45 +040027
Maxim Douninc6acedb2009-10-14 02:23:52 +040028%%TEST_GLOBALS%%
29
Maxim Dounin96a65a72008-09-13 03:37:45 +040030daemon off;
31
32events {
Maxim Dounin96a65a72008-09-13 03:37:45 +040033}
34
35mail {
36 proxy_pass_error_message on;
Maxim Dounin3c472202008-11-02 15:01:41 +030037 auth_http http://127.0.0.1:8080/mail/auth;
Maxim Dounin96a65a72008-09-13 03:37:45 +040038 xclient off;
39
40 server {
Maxim Dounin3c472202008-11-02 15:01:41 +030041 listen 127.0.0.1:8025;
Maxim Dounin96a65a72008-09-13 03:37:45 +040042 protocol smtp;
43 smtp_greeting_delay 100ms;
44 }
45}
46
Maxim Dounin9355e9b2009-01-26 19:22:53 +030047http {
48 # stub to avoid SIGSEGV when perl module compiled in, <= 0.7.30
49}
50
Maxim Dounin96a65a72008-09-13 03:37:45 +040051EOF
52
53###############################################################################
54
55# With smtp_greeting_delay session expected to be closed after first error
56# message if client sent something before greeting.
57
58my $s = Test::Nginx::SMTP->new();
59$s->send('HELO example.com');
60$s->check(qr/^5.. /, "command before greeting - session must be rejected");
Maxim Dounin9355e9b2009-01-26 19:22:53 +030061
62TODO: {
63local $TODO = 'not in official nginx yet';
64
Maxim Dounin96a65a72008-09-13 03:37:45 +040065ok($s->eof(), "session have to be closed");
66
Maxim Dounin9355e9b2009-01-26 19:22:53 +030067}
68
Maxim Dounin96a65a72008-09-13 03:37:45 +040069###############################################################################