Mercurial > hg > nginx-tests
annotate mail_max_commands.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | a095b971fbcc |
children |
rev | line source |
---|---|
1953
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for mail max_commands. |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Socket qw/ CRLF /; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use Test::Nginx::IMAP; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 use Test::Nginx::POP3; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 use Test::Nginx::SMTP; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 ############################################################################### |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 local $SIG{PIPE} = 'IGNORE'; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 my $t = Test::Nginx->new()->has(qw/mail imap pop3 smtp/) |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 ->write_file_expand('nginx.conf', <<'EOF'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 daemon off; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 events { |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 } |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 mail { |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 auth_http http://127.0.0.1:8080; # unused |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 max_commands 1; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 server { |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 listen 127.0.0.1:8143; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 protocol imap; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 } |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 server { |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 listen 127.0.0.1:8110; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 protocol pop3; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 } |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 server { |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 listen 127.0.0.1:8025; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 protocol smtp; |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 } |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 EOF |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
1987
a095b971fbcc
Tests: removed TODO and try_run() checks for legacy versions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1953
diff
changeset
|
63 $t->run()->plan(18); |
1953
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 ############################################################################### |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 # imap |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 my $s = Test::Nginx::IMAP->new(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 $s->read(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 $s->send('a01 NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 $s->check(qr/^a01 OK/, 'imap first noop'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 $s->send('a02 NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 $s->check(qr/^a02 BAD/, 'imap second noop rejected'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 $s->send('a03 NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 $s->check(qr/^$/, 'imap max commands'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 $s = Test::Nginx::IMAP->new(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 $s->read(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 $s->send('a01 NOOP' . CRLF . 'a02 NOOP' . CRLF . 'a03 NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 $s->check(qr/^a01 OK/, 'imap pipelined first noop'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 $s->check(qr/^a02 BAD/, 'imap pipelined second noop rejected'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 $s->check(qr/^$/, 'imap pipelined max commands'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 # pop3 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 $s = Test::Nginx::POP3->new(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 $s->read(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 $s->send('NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 $s->check(qr/^\+OK/, 'pop3 first noop'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 $s->send('NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 $s->check(qr/^-ERR/, 'pop3 second noop'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 $s->send('NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 $s->check(qr/^$/, 'pop3 max commands'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 $s = Test::Nginx::POP3->new(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 $s->read(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 $s->send('NOOP' . CRLF . 'NOOP' . CRLF . 'NOOP'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 $s->check(qr/^\+OK/, 'pop3 pipelined first noop'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 $s->check(qr/^-ERR/, 'pop3 pipelined second noop rejected'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 $s->check(qr/^$/, 'pop3 pipelined max commands'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 # smtp |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 $s = Test::Nginx::SMTP->new(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 $s->read(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 $s->send('RSET'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 $s->check(qr/^2.. /, 'smtp first rset'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 $s->send('RSET'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 $s->check(qr/^5.. /, 'smtp second rset rejected'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 $s->send('RSET'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 $s->check(qr/^$/, 'smtp max commands'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 $s = Test::Nginx::SMTP->new(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 $s->read(); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 $s->send('RSET' . CRLF . 'RSET' . CRLF . 'RSET'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 $s->check(qr/^2.. /, 'smtp pipelined first rset'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 $s->check(qr/^5.. /, 'smtp pipelined second rset rejected'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 $s->check(qr/^$/, 'smtp pipelined max commands'); |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 |
33b54de4ee23
Tests: mail max_commands tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 ############################################################################### |