annotate mail_capability.t @ 1606:e4e0695552ed

Tests: fixed stream_proxy_ssl_conf_command.t. The stream_proxy_ssl_conf_command.t test used stream return module to return the response. Since this ignores actual request, but the perl test code used http_get(). This might result in the request being sent after the response is returned and the connection closed by the server, resulting in RST being generated and no response seen by the client at all. Fix is to use "stream(...)->read()" instead of http_get(), so no request is sent at all, eliminating possibility of RST being generated.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 10 Nov 2020 05:03:29 +0300
parents dbce8fb5f5f8
children ce4a06d72256
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for imap/pop3/smtp capabilities.
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx::IMAP;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 use Test::Nginx::POP3;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 use Test::Nginx::SMTP;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 ###############################################################################
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 select STDERR; $| = 1;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 select STDOUT; $| = 1;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap pop3 smtp/)
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 ->has_daemon('openssl')->plan(17);
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 $t->write_file_expand('nginx.conf', <<'EOF');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 %%TEST_GLOBALS%%
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 daemon off;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 events {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 mail {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 ssl_certificate_key localhost.key;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 ssl_certificate localhost.crt;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 auth_http http://127.0.0.1:8080; # unused
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 pop3_auth plain apop cram-md5;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 listen 127.0.0.1:8143;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 protocol imap;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 imap_capabilities SEE-THIS;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 listen 127.0.0.1:8144;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 protocol imap;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 starttls on;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 listen 127.0.0.1:8145;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 protocol imap;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 starttls only;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 listen 127.0.0.1:8110;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 protocol pop3;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 listen 127.0.0.1:8111;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 protocol pop3;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 starttls on;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 listen 127.0.0.1:8112;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 protocol pop3;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 starttls only;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 listen 127.0.0.1:8025;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 protocol smtp;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 starttls off;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 listen 127.0.0.1:8026;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 protocol smtp;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 starttls on;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 server {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 listen 127.0.0.1:8027;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 protocol smtp;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 starttls only;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 EOF
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 $t->write_file('openssl.conf', <<EOF);
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
106 default_bits = 2048
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 encrypt_key = no
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 distinguished_name = req_distinguished_name
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 [ req_distinguished_name ]
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 EOF
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112 my $d = $t->testdir();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 foreach my $name ('localhost') {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1151
diff changeset
116 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1151
diff changeset
117 . "-out $d/$name.crt -keyout $d/$name.key "
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118 . ">>$d/openssl.out 2>&1") == 0
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 or die "Can't create certificate for $name: $!\n";
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 $t->run();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 ###############################################################################
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 # imap, custom capabilities
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 my $s = Test::Nginx::IMAP->new();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 $s->send('1 CAPABILITY');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 $s->check(qr/^\* CAPABILITY SEE-THIS AUTH=PLAIN/, 'imap capability');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 $s->ok('imap capability completed');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 # imap starttls
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(8144));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 $s->send('1 CAPABILITY');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 $s->check(qr/^\* CAPABILITY IMAP4 IMAP4rev1 UIDPLUS AUTH=PLAIN STARTTLS/,
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 'imap capability starttls');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 # imap starttls only
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(8145));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 $s->send('1 CAPABILITY');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 $s->check(qr/^\* CAPABILITY IMAP4 IMAP4rev1 UIDPLUS STARTTLS LOGINDISABLED/,
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 'imap capability starttls only');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 # pop3
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8110));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 $s->send('CAPA');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 $s->ok('pop3 capa');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 my $caps = get_auth_caps($s);
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 like($caps, qr/USER/, 'pop3 - user');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 like($caps, qr/SASL (PLAIN LOGIN|LOGIN PLAIN) CRAM-MD5/, 'pop3 - methods');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 unlike($caps, qr/STLS/, 'pop3 - no stls');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166 # pop3 starttls
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8111));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171 $s->send('CAPA');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 $caps = get_auth_caps($s);
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174 like($caps, qr/USER/, 'pop3 starttls - user');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 like($caps, qr/SASL (PLAIN LOGIN|LOGIN PLAIN) CRAM-MD5/,
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176 'pop3 starttls - methods');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177 like($caps, qr/STLS/, 'pop3 startls - stls');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
178
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
179 # pop3 starttls only
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
180
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
181 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(8112));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
182 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
183
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
184 $s->send('CAPA');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
185
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
186 $caps = get_auth_caps($s);
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
187 unlike($caps, qr/USER/, 'pop3 starttls only - no user');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
188 unlike($caps, qr/SASL/, 'pop3 starttls only - no methods');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
189 like($caps, qr/STLS/, 'pop3 startls only - stls');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
190
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
191 # smtp
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
192
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
193 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8025));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
194 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
195
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
196 $s->send('EHLO example.com');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
197 $s->check(qr/^250 AUTH PLAIN LOGIN\x0d\x0a?/, 'smtp ehlo');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
198
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
199 # smtp starttls
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
200
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
201 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8026));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
202 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
203
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
204 $s->send('EHLO example.com');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
205 $s->check(qr/^250 STARTTLS/, 'smtp ehlo - starttls');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
206
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
207 # smtp starttls only
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
208
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
209 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8027));
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
210 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
211
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
212 $s->send('EHLO example.com');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
213 $s->check(qr/^250 STARTTLS/, 'smtp ehlo - starttls only');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
214
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
215 ###############################################################################
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
217 sub get_auth_caps {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
218 my ($s) = @_;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
219 my @meth;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
220
1151
57673c7257a3 Tests: unbreak mail tests in case of EOF.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1146
diff changeset
221 while ($s->read()) {
57673c7257a3 Tests: unbreak mail tests in case of EOF.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1146
diff changeset
222 last if /^\./;
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
223 push @meth, $1 if /(.*?)\x0d\x0a?/ms;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
224 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
225 join ':', @meth;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
226 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
227
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
228 ###############################################################################