Mercurial > hg > nginx-tests
annotate lib/Test/Nginx/IMAP.pm @ 1742:7bfa47410cc0
Tests: basic ALPN tests in the mail module.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 21 Oct 2021 13:56:16 +0300 |
parents | e7f0b4ca0a1a |
children | 5d3aee48ed8e |
rev | line source |
---|---|
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 package Test::Nginx::IMAP; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Module for nginx imap tests. |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More qw//; |
1244
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
969
diff
changeset
|
13 use IO::Select; |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 use IO::Socket; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 use Socket qw/ CRLF /; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
540
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
19 sub new { |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
20 my $self = {}; |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
21 bless $self, shift @_; |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
540
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
23 $self->{_socket} = IO::Socket::INET->new( |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 Proto => "tcp", |
969
1edb092149e2
Tests: simplified parallel tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
951
diff
changeset
|
25 PeerAddr => "127.0.0.1:" . port(8143), |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 @_ |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 ) |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 or die "Can't connect to nginx: $!\n"; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
540
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
30 if ({@_}->{'SSL'}) { |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
31 require IO::Socket::SSL; |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
32 IO::Socket::SSL->start_SSL($self->{_socket}, @_) |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
33 or die $IO::Socket::SSL::SSL_ERROR . "\n"; |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
34 } |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
35 |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
36 $self->{_socket}->autoflush(1); |
1678
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
37 $self->{_read_buffer} = ''; |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 return $self; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
540
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
42 sub eof { |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
43 my $self = shift; |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
44 return $self->{_socket}->eof(); |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
45 } |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
46 |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
47 sub print { |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
48 my ($self, $cmd) = @_; |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
49 log_out($cmd); |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
50 $self->{_socket}->print($cmd); |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
51 } |
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
52 |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 sub send { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 my ($self, $cmd) = @_; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 log_out($cmd); |
540
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
56 $self->{_socket}->print($cmd . CRLF); |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 |
1678
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
59 sub getline { |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
60 my ($self) = @_; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
61 my $socket = $self->{_socket}; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
62 |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
63 if ($self->{_read_buffer} =~ /^(.*?\x0a)(.*)/ms) { |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
64 $self->{_read_buffer} = $2; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
65 return $1; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
66 } |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
67 |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
68 while (IO::Select->new($socket)->can_read(8)) { |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
69 $socket->blocking(0); |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
70 my $n = $socket->sysread(my $buf, 1024); |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
71 $socket->blocking(1); |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
72 last unless $n; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
73 |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
74 $self->{_read_buffer} .= $buf; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
75 |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
76 if ($self->{_read_buffer} =~ /^(.*?\x0a)(.*)/ms) { |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
77 $self->{_read_buffer} = $2; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
78 return $1; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
79 } |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
80 }; |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
81 } |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
82 |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 sub read { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 my ($self) = @_; |
540
481d705b8610
Tests: SSL support in mail backends.
Sergey Kandaurov <pluknet@nginx.com>
parents:
539
diff
changeset
|
85 my $socket = $self->{_socket}; |
1678
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
86 |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
87 while (defined($_ = $self->getline())) { |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
88 log_in($_); |
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
89 last; |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 } |
1678
d0025a0dead7
Tests: better timeout handling in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1423
diff
changeset
|
91 |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 return $_; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 sub check { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 my ($self, $regex, $name) = @_; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 Test::More->builder->like($self->read(), $regex, $name); |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 sub ok { |
243
de7338227832
Tests: removed trailing spaces.
Homutov Vladimir <vl@nginx.com>
parents:
209
diff
changeset
|
101 my $self = shift; |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 Test::More->builder->like($self->read(), qr/^\S+ OK/, @_); |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 |
1244
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
969
diff
changeset
|
105 sub can_read { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
969
diff
changeset
|
106 my ($self, $timo) = @_; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
969
diff
changeset
|
107 IO::Select->new($self->{_socket})->can_read($timo || 3); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
969
diff
changeset
|
108 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
969
diff
changeset
|
109 |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 ############################################################################### |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 sub imap_test_daemon { |
951
9361c7eddfc1
Tests: parallel tests support.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
540
diff
changeset
|
113 my ($port) = @_; |
9361c7eddfc1
Tests: parallel tests support.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
540
diff
changeset
|
114 |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 my $server = IO::Socket::INET->new( |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 Proto => 'tcp', |
969
1edb092149e2
Tests: simplified parallel tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
951
diff
changeset
|
117 LocalAddr => '127.0.0.1:' . ($port || port(8144)), |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 Listen => 5, |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 Reuse => 1 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 ) |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 or die "Can't create listening socket: $!\n"; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 while (my $client = $server->accept()) { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 $client->autoflush(1); |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 print $client "* OK fake imap server ready" . CRLF; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 while (<$client>) { |
1684
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
128 Test::Nginx::log_core('||', $_); |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
129 |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
130 while (m/{(\d+)}\x0d?$/) { |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
131 print $client '+ ' . CRLF; |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
132 $client->sysread(my $buf, $1); |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
133 Test::Nginx::log_core('||', $buf); |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
134 $buf = <$client>; |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
135 Test::Nginx::log_core('||', $buf); |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
136 $_ .= $buf; |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
137 } |
e7f0b4ca0a1a
Tests: literals support in IMAP test backend.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1678
diff
changeset
|
138 |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 my $tag = ''; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 $tag = $1 if m/^(\S+)/; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 s/^(\S+)\s+//; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 if (/^logout/i) { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 print $client $tag . ' OK logout ok' . CRLF; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 } elsif (/^login /i) { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 print $client $tag . ' OK login ok' . CRLF; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 } else { |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 print $client $tag . ' ERR unknown command' . CRLF; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 } |
539
3fcad5e66735
Tests: whitespace fixes in mail modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
526
diff
changeset
|
151 } |
59
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 close $client; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 } |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 ############################################################################### |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 1; |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 |
bc3351f157ef
Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 ############################################################################### |