Mercurial > hg > nginx-tests
annotate mail_capability.t @ 1248:70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
The stream js tests introduced in edf5a3c9e36a fail on njs 0.1.14. It doesn't
currently provide an easy way to check its version, whilst we are obligated to
gracefully handle such cases somehow. With such an addition of 'require', now
the tests are skipped instead on the previous versions.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Nov 2017 13:16:39 +0300 |
parents | 0af58b78df35 |
children | 766bcbb632ee |
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 ] |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 default_bits = 1024 |
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 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 TODO: { |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 local $TODO = 'not yet' if $t->has_version('1.11.6') |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 and !$t->has_version('1.11.11'); |
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 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
|
169 |
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 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 unlike($caps, qr/STLS/, 'pop3 - no stls'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 # pop3 starttls |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 $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
|
177 $s->read(); |
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 $s->send('CAPA'); |
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 $caps = get_auth_caps($s); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 like($caps, qr/USER/, 'pop3 starttls - user'); |
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 TODO: { |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 local $TODO = 'not yet' if $t->has_version('1.11.6') |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 and !$t->has_version('1.11.11'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 like($caps, qr/SASL (PLAIN LOGIN|LOGIN PLAIN) CRAM-MD5/, |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 'pop3 starttls - methods'); |
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 } |
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 like($caps, qr/STLS/, 'pop3 startls - stls'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 # pop3 starttls only |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 $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
|
198 $s->read(); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 $s->send('CAPA'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 $caps = get_auth_caps($s); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 unlike($caps, qr/USER/, 'pop3 starttls only - no user'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 unlike($caps, qr/SASL/, 'pop3 starttls only - no methods'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 like($caps, qr/STLS/, 'pop3 startls only - stls'); |
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 |
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(8025)); |
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 AUTH PLAIN LOGIN\x0d\x0a?/, 'smtp ehlo'); |
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 # smtp starttls |
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 $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
|
218 $s->read(); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 $s->send('EHLO example.com'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 $s->check(qr/^250 STARTTLS/, 'smtp ehlo - starttls'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 # smtp starttls only |
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 $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
|
226 $s->read(); |
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 $s->send('EHLO example.com'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 $s->check(qr/^250 STARTTLS/, 'smtp ehlo - starttls only'); |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 ############################################################################### |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 sub get_auth_caps { |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 my ($s) = @_; |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 my @meth; |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 |
1151
57673c7257a3
Tests: unbreak mail tests in case of EOF.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1146
diff
changeset
|
237 while ($s->read()) { |
57673c7257a3
Tests: unbreak mail tests in case of EOF.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1146
diff
changeset
|
238 last if /^\./; |
1146
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 push @meth, $1 if /(.*?)\x0d\x0a?/ms; |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 } |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 join ':', @meth; |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 } |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 |
2634d0ef48d3
Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 ############################################################################### |