annotate mail_imap.t @ 1427:eb1d883305ea

Tests: avoid edge cases in upstream random two test. Unavailable servers contribute to the number of attempts, if selected, before the balancer would fall back to the default round-robin method. This means that it's quite possible to get server with more connections. To facilitate with selecting two alive servers, down server was removed from the upstream configuration at the cost of slightly worse coverage.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 10 Jan 2019 17:42:34 +0300
parents 766bcbb632ee
children 74986ebee2fd
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 imap 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;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18 use lib 'lib';
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 use Test::Nginx;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20 use Test::Nginx::IMAP;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21
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 select STDERR; $| = 1;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25 select STDOUT; $| = 1;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26
96
ecff5407867c Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents: 75
diff changeset
27 local $SIG{PIPE} = 'IGNORE';
ecff5407867c Tests: better handle unexpected connection close from nginx.
Maxim Dounin <mdounin@mdounin.ru>
parents: 75
diff changeset
28
1111
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
29 my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/)
976
a8b8dd6e8ae1 Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 970
diff changeset
30 ->write_file_expand('nginx.conf', <<'EOF');
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 96
diff changeset
32 %%TEST_GLOBALS%%
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 96
diff changeset
33
249
6a0d934950bc Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents: 166
diff changeset
34 daemon off;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 events {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 }
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 mail {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 proxy_pass_error_message on;
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
41 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
42
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43 server {
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
44 listen 127.0.0.1:8143;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45 protocol imap;
1111
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
46 imap_auth plain cram-md5 external;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
48 }
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 http {
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 96
diff changeset
51 %%TEST_GLOBALS_HTTP%%
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
53 server {
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
54 listen 127.0.0.1:8080;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
55 server_name localhost;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
56
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57 location = /mail/auth {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 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
59 set $passw "";
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
61 if ($http_auth_smtp_to ~ example.com) {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 set $reply OK;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
65 set $userpass "$http_auth_user:$http_auth_pass";
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
66 if ($userpass ~ '^test@example.com:secret$') {
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
67 set $reply OK;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
68 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
69
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
70 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
71 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
72 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
73 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
74 }
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
75
1110
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
76 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
77 if ($userpass ~ '^external:test@example.com:$') {
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
78 set $reply OK;
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
79 set $passw secret;
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
80 }
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
81
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
82 add_header Auth-Status $reply;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83 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
84 add_header Auth-Port %%PORT_8144%%;
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
85 add_header Auth-Pass $passw;
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86 add_header Auth-Wait 1;
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
87 return 204;
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 }
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
91
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
92 EOF
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
93
976
a8b8dd6e8ae1 Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 970
diff changeset
94 $t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon);
1251
766bcbb632ee Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1111
diff changeset
95 $t->run()->plan(14);
1111
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
96
6c2538ad642d Tests: auth external in mail is explicitly enabled since 1.11.9.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1110
diff changeset
97 $t->waitforsocket('127.0.0.1:' . port(8144));
976
a8b8dd6e8ae1 Tests: changed startup order in mail tests for consistency.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 970
diff changeset
98
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
99 ###############################################################################
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
100
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
101 my $s = Test::Nginx::IMAP->new();
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
102 $s->ok('greeting');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
103
151
1c39b7edc593 Tests: make sure imap authenticate without arguments fails.
Maxim Dounin <mdounin@mdounin.ru>
parents: 148
diff changeset
104 # bad auth
1c39b7edc593 Tests: make sure imap authenticate without arguments fails.
Maxim Dounin <mdounin@mdounin.ru>
parents: 148
diff changeset
105
1c39b7edc593 Tests: make sure imap authenticate without arguments fails.
Maxim Dounin <mdounin@mdounin.ru>
parents: 148
diff changeset
106 $s->send('1 AUTHENTICATE');
1c39b7edc593 Tests: make sure imap authenticate without arguments fails.
Maxim Dounin <mdounin@mdounin.ru>
parents: 148
diff changeset
107 $s->check(qr/^\S+ BAD/, 'auth without arguments');
1c39b7edc593 Tests: make sure imap authenticate without arguments fails.
Maxim Dounin <mdounin@mdounin.ru>
parents: 148
diff changeset
108
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
109 # auth plain
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
110
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
111 $s->send('1 AUTHENTICATE PLAIN ' . encode_base64("\0test\@example.com\0bad", ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
112 $s->check(qr/^\S+ NO/, 'auth plain with bad password');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
113
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
114 $s->send('1 AUTHENTICATE PLAIN ' . encode_base64("\0test\@example.com\0secret", ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
115 $s->ok('auth plain');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
116
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
117 # auth login simple
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
118
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
119 $s = Test::Nginx::IMAP->new();
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
120 $s->read();
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
121
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
122 $s->send('1 AUTHENTICATE LOGIN');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
123 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth login username challenge');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
124
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
125 $s->send(encode_base64('test@example.com', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
126 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login password challenge');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
127
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
128 $s->send(encode_base64('secret', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
129 $s->ok('auth login simple');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
130
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131 # auth login with username
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132
970
c227348453db Tests: simplified parallel modifications in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 952
diff changeset
133 $s = Test::Nginx::IMAP->new();
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
134 $s->read();
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
135
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
136 $s->send('1 AUTHENTICATE LOGIN ' . encode_base64('test@example.com', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
137 $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
138
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
139 $s->send(encode_base64('secret', ''));
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
140 $s->ok('auth login with username');
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
141
1109
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
142 # 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
143
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
144 $s = Test::Nginx::IMAP->new();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
145 $s->read();
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
146
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
147 $s->send('1 AUTHENTICATE CRAM-MD5');
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
148 $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
149
59d5c8ca7e4d Tests: auth cram-md5 mail tests, pop3 user/pass and apop tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 976
diff changeset
150 $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
151 $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
152
1110
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
153 # auth external
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
154
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
155 $s = Test::Nginx::IMAP->new();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
156 $s->read();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
157
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
158 $s->send('1 AUTHENTICATE EXTERNAL');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
159 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth external challenge');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
160
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
161 $s->send(encode_base64('test@example.com', ''));
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
162 $s->ok('auth external');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
163
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
164 # auth external with username
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
165
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
166 $s = Test::Nginx::IMAP->new();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
167 $s->read();
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
168
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
169 $s->send('1 AUTHENTICATE EXTERNAL ' . encode_base64('test@example.com', ''));
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
170 $s->ok('auth external with username');
b9b115a2a28d Tests: auth external mail tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1109
diff changeset
171
59
bc3351f157ef Tests: add basic pop3 and imap tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
172 ###############################################################################