annotate mail_pop3.t @ 1851:0351dee227a8

Tests: unbreak tests with dynamic certificates on stable. In 74cffa9d4c43, ticket based session reuse is enabled in addition to using a shared SSL session cache. This changed how a session can be resumed in a different server: - for a session ID based resumption, it is resumed in the same context - when using session tickets, a key name is also checked for matching - with a ticket callback, this is skipped in favor of callback's logic This makes 'session id context match' tests fail with session tickets on stable since ticket key names are unique in distinct SSL contexts. On the other hand, tests pass on 1.23.2+ due to automatic ticket keys rotation that installs ticket callback, and using a common shared SSL session cache.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 28 Mar 2023 01:36:32 +0400
parents 994d1b58cbe8
children 2a0a6035a1af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1 #!/usr/bin/perl
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 # Tests for nginx mail pop3 module.
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;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14 use MIME::Base64;
1683
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
15 use Socket qw/ CRLF /;
59
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 BEGIN { use FindBin; chdir($FindBin::Bin); }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 use lib 'lib';
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20 use Test::Nginx;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21 use Test::Nginx::POP3;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23 ###############################################################################
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25 select STDERR; $| = 1;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26 select STDOUT; $| = 1;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27
96
ecff5407867c Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents: 75
diff changeset
28 local $SIG{PIPE} = 'IGNORE';
ecff5407867c Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents: 75
diff changeset
29
1111
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
30 my $t = Test::Nginx->new()->has(qw/mail pop3 http rewrite/)
976
a8b8dd6e8ae1 Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 970
diff changeset
31 ->write_file_expand('nginx.conf', <<'EOF');
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 96
diff changeset
33 %%TEST_GLOBALS%%
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 96
diff changeset
34
249
6a0d934950bc Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents: 166
diff changeset
35 daemon off;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 events {
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
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 mail {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41 proxy_pass_error_message on;
1679
74986ebee2fd Tests: added proxy_timeout in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1251
diff changeset
42 proxy_timeout 15s;
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
43 auth_http http://127.0.0.1:8080/mail/auth;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45 server {
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
46 listen 127.0.0.1:8110;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47 protocol pop3;
1111
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
48 pop3_auth plain apop cram-md5 external;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
49 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
51
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 http {
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 96
diff changeset
53 %%TEST_GLOBALS_HTTP%%
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
55 server {
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
56 listen 127.0.0.1:8080;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57 server_name localhost;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 location = /mail/auth {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 set $reply ERROR;
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
61 set $passw "";
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 set $userpass "$http_auth_user:$http_auth_pass";
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64 if ($userpass ~ '^test@example.com:secret$') {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
65 set $reply OK;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
66 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
67
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
68 set $userpass "$http_auth_user:$http_auth_salt:$http_auth_pass";
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
69 if ($userpass ~ '^test@example.com:<.*@.*>:0{32}$') {
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
70 set $reply OK;
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
71 set $passw secret;
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
72 }
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
73
1110
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
74 set $userpass "$http_auth_method:$http_auth_user:$http_auth_pass";
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
75 if ($userpass ~ '^external:test@example.com:$') {
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
76 set $reply OK;
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
77 set $passw secret;
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
78 }
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
79
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 add_header Auth-Status $reply;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81 add_header Auth-Server 127.0.0.1;
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
82 add_header Auth-Port %%PORT_8111%%;
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
83 add_header Auth-Pass $passw;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
84 add_header Auth-Wait 1;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
85 return 204;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
87 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
88 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
89
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
90 EOF
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
91
976
a8b8dd6e8ae1 Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 970
diff changeset
92 $t->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon);
1683
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
93 $t->run()->plan(28);
1111
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
94
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
95 $t->waitforsocket('127.0.0.1:' . port(8111));
976
a8b8dd6e8ae1 Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 970
diff changeset
96
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
97 ###############################################################################
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
98
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
99 my $s = Test::Nginx::POP3->new();
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
100 $s->ok('greeting');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
101
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
102 # user / pass
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
103
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
104 $s->send('USER test@example.com');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
105 $s->ok('user');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
106
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
107 $s->send('PASS secret');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
108 $s->ok('pass');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
110 # apop
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
111
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
112 $s = Test::Nginx::POP3->new();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
113 $s->check(qr/<.*\@.*>/, 'apop salt');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
114
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
115 $s->send('APOP test@example.com ' . ('1' x 32));
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
116 $s->check(qr/^-ERR/, 'apop error');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
117
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
118 $s->send('APOP test@example.com ' . ('0' x 32));
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
119 $s->ok('apop');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
120
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
121 # auth capabilities
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
122
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
123 $s = Test::Nginx::POP3->new();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
124 $s->read();
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
125
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
126 $s->send('AUTH');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
127 $s->ok('auth');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
128
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
129 is(get_auth_caps($s), 'PLAIN:LOGIN:CRAM-MD5:EXTERNAL', 'auth capabilities');
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
130
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131 # auth plain
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
133 $s = Test::Nginx::POP3->new();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
134 $s->read();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
135
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
136 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0bad", ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
137 $s->check(qr/^-ERR/, 'auth plain with bad password');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
138
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
139 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
140 $s->ok('auth plain');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
141
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
142 # auth login simple
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
143
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
144 $s = Test::Nginx::POP3->new();
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
145 $s->read();
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
146
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
147 $s->send('AUTH LOGIN');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
148 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth login username challenge');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
149
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
150 $s->send(encode_base64('test@example.com', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
151 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login password challenge');
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 $s->send(encode_base64('secret', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
154 $s->ok('auth login simple');
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 # auth login with username
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
157
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
158 $s = Test::Nginx::POP3->new();
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
159 $s->read();
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 $s->send('AUTH LOGIN ' . encode_base64('test@example.com', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
162 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login with username password challenge');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
163
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
164 $s->send(encode_base64('secret', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
165 $s->ok('auth login with username');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
166
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
167 # auth cram-md5
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
168
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
169 $s = Test::Nginx::POP3->new();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
170 $s->read();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
171
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
172 $s->send('AUTH CRAM-MD5');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
173 $s->check(qr/\+ /, 'auth cram-md5 challenge');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
174
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
175 $s->send(encode_base64('test@example.com ' . ('0' x 32), ''));
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
176 $s->ok('auth cram-md5');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
177
1110
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
178 # auth external
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
179
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
180 $s = Test::Nginx::POP3->new();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
181 $s->read();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
182
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
183 $s->send('AUTH EXTERNAL');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
184 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth external challenge');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
185
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
186 $s->send(encode_base64('test@example.com', ''));
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
187 $s->ok('auth external');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
188
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
189 # auth external with username
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
190
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
191 $s = Test::Nginx::POP3->new();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
192 $s->read();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
193
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
194 $s->send('AUTH EXTERNAL ' . encode_base64('test@example.com', ''));
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
195 $s->ok('auth external with username');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
196
1683
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
197 # pipelining
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
198
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
199 $s = Test::Nginx::POP3->new();
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
200 $s->read();
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
201
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
202 $s->send('INVALID COMMAND WITH ARGUMENTS' . CRLF
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
203 . 'NOOP');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
204 $s->check(qr/^-ERR/, 'pipelined invalid command');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
205
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
206 TODO: {
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
207 local $TODO = 'not yet' unless $t->has_version('1.21.0');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
208
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
209 $s->ok('pipelined noop after invalid command');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
210
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
211 }
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
212
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
213 $s->send('USER test@example.com' . CRLF
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
214 . 'PASS secret' . CRLF
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
215 . 'QUIT');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
216 $s->ok('pipelined user');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
217
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
218 TODO: {
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
219 local $TODO = 'not yet' unless $t->has_version('1.21.0');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
220
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
221 $s->ok('pipelined pass');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
222 $s->ok('pipelined quit');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
223
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
224 }
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
225
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
226 $s = Test::Nginx::POP3->new();
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
227 $s->read();
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
228
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
229 $s->send('AUTH LOGIN' . CRLF
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
230 . encode_base64('test@example.com', '') . CRLF
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
231 . encode_base64('secret', ''));
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
232 $s->check(qr/\+ VXNlcm5hbWU6/, 'pipelined auth username challenge');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
233
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
234 TODO: {
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
235 local $TODO = 'not yet' unless $t->has_version('1.21.0');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
236
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
237 $s->check(qr/\+ UGFzc3dvcmQ6/, 'pipelined auth password challenge');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
238 $s->ok('pipelined auth');
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
239
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
240 }
994d1b58cbe8 Tests: POP3 pipelining tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 1680
diff changeset
241
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
242 ###############################################################################
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
243
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
244 sub get_auth_caps {
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
245 my ($s) = @_;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
246 my @meth;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
247
1151
57673c7257a3 Tests: unbreak mail tests in case of EOF.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1146
diff changeset
248 while ($s->read()) {
57673c7257a3 Tests: unbreak mail tests in case of EOF.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1146
diff changeset
249 last if /^\./;
1146
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
250 push @meth, $1 if /(.*?)\x0d\x0a?/ms;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
251 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
252 join ':', @meth;
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
253 }
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
254
2634d0ef48d3 Tests: mail capability tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
255 ###############################################################################