Mercurial > hg > nginx-tests
annotate mail_smtp_greeting_delay.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 74986ebee2fd |
children |
rev | line source |
---|---|
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 ############################################################################### |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 use warnings; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 use strict; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
27
fb94a224fef2
Tests: add has() functions for feature testing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
26
diff
changeset
|
10 use Test::More; |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 BEGIN { use FindBin; chdir($FindBin::Bin); } |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 use lib 'lib'; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 use Test::Nginx; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use Test::Nginx::SMTP; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 ############################################################################### |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 select STDERR; $| = 1; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDOUT; $| = 1; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
159
b5d0fcb02980
Tests: ignore SIGPIPE in mail_smtp_greeting_delay.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
148
diff
changeset
|
23 local $SIG{PIPE} = 'IGNORE'; |
b5d0fcb02980
Tests: ignore SIGPIPE in mail_smtp_greeting_delay.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
148
diff
changeset
|
24 |
1243
6ea73d9f42e0
Tests: removed http prerequisite from mail_smtp_greeting_delay.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
970
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/mail smtp/)->plan(2) |
27
fb94a224fef2
Tests: add has() functions for feature testing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
26
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF')->run(); |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
66
diff
changeset
|
28 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
66
diff
changeset
|
29 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
30 daemon off; |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 events { |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 } |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 mail { |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 proxy_pass_error_message on; |
1679
74986ebee2fd
Tests: added proxy_timeout in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1243
diff
changeset
|
37 proxy_timeout 15s; |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
38 auth_http http://127.0.0.1:8080/mail/auth; |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 xclient off; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 server { |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
42 listen 127.0.0.1:8025; |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 protocol smtp; |
913
dba252c2afd6
Tests: adjusted smtp_greeting_delay test timeout for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
44 smtp_greeting_delay 1s; |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 } |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 EOF |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 ############################################################################### |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 # With smtp_greeting_delay session expected to be closed after first error |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 # message if client sent something before greeting. |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
970
c227348453db
Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
952
diff
changeset
|
55 my $s = Test::Nginx::SMTP->new(); |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 $s->send('HELO example.com'); |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 $s->check(qr/^5.. /, "command before greeting - session must be rejected"); |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 ok($s->eof(), "session have to be closed"); |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 ############################################################################### |