Mercurial > hg > nginx-tests
annotate mail_smtp_greeting_delay.t @ 289:cbd4f6eca676
Tests: check if started process is alive while starting nginx.
This allows faster test execution in case of startup failures, e.g.
due to configuration errors. Note that just adding waitpid() to
waitforfile() causes hang on win32 in wait(). To fix this, wait()
calls were changed to waitpid() with pid specified.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 27 May 2013 17:15:17 +0400 |
parents | 6a0d934950bc |
children | c6b1430afc66 |
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 |
121
8ac1faaddd2c
Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/mail smtp http/)->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; |
45
d68b85def521
Tests: use 127.0.0.1 instead of localhost.
Maxim Dounin <mdounin@mdounin.ru>
parents:
36
diff
changeset
|
37 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
|
38 xclient off; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server { |
45
d68b85def521
Tests: use 127.0.0.1 instead of localhost.
Maxim Dounin <mdounin@mdounin.ru>
parents:
36
diff
changeset
|
41 listen 127.0.0.1:8025; |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 protocol smtp; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 smtp_greeting_delay 100ms; |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 } |
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 |
66
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
47 http { |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
48 # stub to avoid SIGSEGV when perl module compiled in, <= 0.7.30 |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
49 } |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
50 |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 EOF |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 ############################################################################### |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 # 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
|
56 # message if client sent something before greeting. |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 my $s = Test::Nginx::SMTP->new(); |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 $s->send('HELO example.com'); |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 $s->check(qr/^5.. /, "command before greeting - session must be rejected"); |
66
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
61 |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
62 TODO: { |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
63 local $TODO = 'not in official nginx yet'; |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
64 |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 ok($s->eof(), "session have to be closed"); |
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
66
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
67 } |
b4f1e64882b7
Tests: cleanup smtp-greeting-delay test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
68 |
17
7e28c64edf55
Tests: reorganize smtp tests (no real changes).
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 ############################################################################### |