Mercurial > hg > nginx-tests
comparison worker_shutdown_timeout_mail.t @ 1244:575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 20 Nov 2017 17:55:22 +0300 |
parents | |
children | caf59f42a3e1 |
comparison
equal
deleted
inserted
replaced
1243:6ea73d9f42e0 | 1244:575d39cc0e35 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for worker_shutdown_timeout directive within the mail module. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 use MIME::Base64; | |
16 | |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
18 | |
19 use lib 'lib'; | |
20 use Test::Nginx; | |
21 use Test::Nginx::SMTP; | |
22 | |
23 ############################################################################### | |
24 | |
25 select STDERR; $| = 1; | |
26 select STDOUT; $| = 1; | |
27 | |
28 local $SIG{PIPE} = 'IGNORE'; | |
29 | |
30 my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/)->plan(4) | |
31 ->write_file_expand('nginx.conf', <<'EOF'); | |
32 | |
33 %%TEST_GLOBALS%% | |
34 | |
35 daemon off; | |
36 worker_shutdown_timeout 10ms; | |
37 | |
38 events { | |
39 } | |
40 | |
41 mail { | |
42 proxy_pass_error_message on; | |
43 auth_http http://127.0.0.1:8080/mail/auth; | |
44 xclient off; | |
45 | |
46 server { | |
47 listen 127.0.0.1:8025; | |
48 protocol smtp; | |
49 } | |
50 } | |
51 | |
52 http { | |
53 %%TEST_GLOBALS_HTTP%% | |
54 | |
55 server { | |
56 listen 127.0.0.1:8080; | |
57 server_name localhost; | |
58 | |
59 location = /mail/auth { | |
60 add_header Auth-Status OK; | |
61 add_header Auth-Server 127.0.0.1; | |
62 add_header Auth-Port %%PORT_8026%%; | |
63 add_header Auth-Wait 1; | |
64 return 204; | |
65 } | |
66 } | |
67 } | |
68 | |
69 EOF | |
70 | |
71 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); | |
72 $t->run()->waitforsocket('127.0.0.1:' . port(8026)); | |
73 | |
74 ############################################################################### | |
75 | |
76 my $s = Test::Nginx::SMTP->new(); | |
77 $s->check(qr/^220 /, "greeting"); | |
78 | |
79 $s->send('EHLO example.com'); | |
80 $s->check(qr/^250 /, "ehlo"); | |
81 | |
82 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | |
83 $s->authok('auth plain'); | |
84 | |
85 $t->reload(); | |
86 | |
87 TODO: { | |
88 local $TODO = 'not yet' unless $t->has_version('1.13.7'); | |
89 | |
90 ok($s->can_read(), 'mail connection shutdown'); | |
91 | |
92 } | |
93 | |
94 undef $s; | |
95 | |
96 ############################################################################### |