Mercurial > hg > nginx-tests
comparison mail_max_commands.t @ 1953:33b54de4ee23
Tests: mail max_commands tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 30 Mar 2024 07:19:11 +0300 |
parents | |
children | a095b971fbcc |
comparison
equal
deleted
inserted
replaced
1952:92d90cc5f5e5 | 1953:33b54de4ee23 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for mail max_commands. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
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::IMAP; | |
20 use Test::Nginx::POP3; | |
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 pop3 smtp/) | |
31 ->write_file_expand('nginx.conf', <<'EOF'); | |
32 | |
33 %%TEST_GLOBALS%% | |
34 | |
35 daemon off; | |
36 | |
37 events { | |
38 } | |
39 | |
40 mail { | |
41 auth_http http://127.0.0.1:8080; # unused | |
42 | |
43 max_commands 1; | |
44 | |
45 server { | |
46 listen 127.0.0.1:8143; | |
47 protocol imap; | |
48 } | |
49 | |
50 server { | |
51 listen 127.0.0.1:8110; | |
52 protocol pop3; | |
53 } | |
54 | |
55 server { | |
56 listen 127.0.0.1:8025; | |
57 protocol smtp; | |
58 } | |
59 } | |
60 | |
61 EOF | |
62 | |
63 $t->try_run('no max_commands')->plan(18); | |
64 | |
65 ############################################################################### | |
66 | |
67 # imap | |
68 | |
69 my $s = Test::Nginx::IMAP->new(); | |
70 $s->read(); | |
71 | |
72 $s->send('a01 NOOP'); | |
73 $s->check(qr/^a01 OK/, 'imap first noop'); | |
74 $s->send('a02 NOOP'); | |
75 $s->check(qr/^a02 BAD/, 'imap second noop rejected'); | |
76 $s->send('a03 NOOP'); | |
77 $s->check(qr/^$/, 'imap max commands'); | |
78 | |
79 $s = Test::Nginx::IMAP->new(); | |
80 $s->read(); | |
81 | |
82 $s->send('a01 NOOP' . CRLF . 'a02 NOOP' . CRLF . 'a03 NOOP'); | |
83 $s->check(qr/^a01 OK/, 'imap pipelined first noop'); | |
84 $s->check(qr/^a02 BAD/, 'imap pipelined second noop rejected'); | |
85 $s->check(qr/^$/, 'imap pipelined max commands'); | |
86 | |
87 # pop3 | |
88 | |
89 $s = Test::Nginx::POP3->new(); | |
90 $s->read(); | |
91 | |
92 $s->send('NOOP'); | |
93 $s->check(qr/^\+OK/, 'pop3 first noop'); | |
94 $s->send('NOOP'); | |
95 $s->check(qr/^-ERR/, 'pop3 second noop'); | |
96 $s->send('NOOP'); | |
97 $s->check(qr/^$/, 'pop3 max commands'); | |
98 | |
99 $s = Test::Nginx::POP3->new(); | |
100 $s->read(); | |
101 | |
102 $s->send('NOOP' . CRLF . 'NOOP' . CRLF . 'NOOP'); | |
103 $s->check(qr/^\+OK/, 'pop3 pipelined first noop'); | |
104 $s->check(qr/^-ERR/, 'pop3 pipelined second noop rejected'); | |
105 $s->check(qr/^$/, 'pop3 pipelined max commands'); | |
106 | |
107 # smtp | |
108 | |
109 $s = Test::Nginx::SMTP->new(); | |
110 $s->read(); | |
111 | |
112 $s->send('RSET'); | |
113 $s->check(qr/^2.. /, 'smtp first rset'); | |
114 $s->send('RSET'); | |
115 $s->check(qr/^5.. /, 'smtp second rset rejected'); | |
116 $s->send('RSET'); | |
117 $s->check(qr/^$/, 'smtp max commands'); | |
118 | |
119 $s = Test::Nginx::SMTP->new(); | |
120 $s->read(); | |
121 | |
122 $s->send('RSET' . CRLF . 'RSET' . CRLF . 'RSET'); | |
123 $s->check(qr/^2.. /, 'smtp pipelined first rset'); | |
124 $s->check(qr/^5.. /, 'smtp pipelined second rset rejected'); | |
125 $s->check(qr/^$/, 'smtp pipelined max commands'); | |
126 | |
127 ############################################################################### |