comparison smtp-greeting-delay.t @ 17:7e28c64edf55

Tests: reorganize smtp tests (no real changes). Move smtp_greeting_delay tests into separate test file. Embed config into tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 13 Sep 2008 03:37:45 +0400
parents
children 0880e0fafde4
comparison
equal deleted inserted replaced
16:dc0f15a3a140 17:7e28c64edf55
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 ###############################################################################
6
7 use warnings;
8 use strict;
9
10 use Test::More tests => 2;
11
12 use MIME::Base64;
13 use Socket qw/ CRLF /;
14
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16
17 use lib 'lib';
18 use Test::Nginx;
19 use Test::Nginx::SMTP;
20
21 ###############################################################################
22
23 select STDERR; $| = 1;
24 select STDOUT; $| = 1;
25
26 my $t = Test::Nginx->new()->write_file_expand('nginx.conf', <<'EOF')->run();
27
28 master_process off;
29 daemon off;
30
31 events {
32 worker_connections 1024;
33 }
34
35 mail {
36 proxy_pass_error_message on;
37 auth_http http://localhost:8080/mail/auth;
38 xclient off;
39
40 server {
41 listen localhost:10025;
42 protocol smtp;
43 smtp_greeting_delay 100ms;
44 }
45 }
46
47 EOF
48
49 ###############################################################################
50
51 # With smtp_greeting_delay session expected to be closed after first error
52 # message if client sent something before greeting.
53
54 my $s = Test::Nginx::SMTP->new();
55 $s->send('HELO example.com');
56 $s->check(qr/^5.. /, "command before greeting - session must be rejected");
57 ok($s->eof(), "session have to be closed");
58
59 ###############################################################################