Mercurial > hg > nginx-tests
comparison mail_imap.t @ 1110:b9b115a2a28d
Tests: auth external mail tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 12 Jan 2017 13:02:23 +0300 |
parents | 59d5c8ca7e4d |
children | 6c2538ad642d |
comparison
equal
deleted
inserted
replaced
1109:59d5c8ca7e4d | 1110:b9b115a2a28d |
---|---|
24 select STDERR; $| = 1; | 24 select STDERR; $| = 1; |
25 select STDOUT; $| = 1; | 25 select STDOUT; $| = 1; |
26 | 26 |
27 local $SIG{PIPE} = 'IGNORE'; | 27 local $SIG{PIPE} = 'IGNORE'; |
28 | 28 |
29 my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/)->plan(11) | 29 my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/)->plan(14) |
30 ->write_file_expand('nginx.conf', <<'EOF'); | 30 ->write_file_expand('nginx.conf', <<'EOF'); |
31 | 31 |
32 %%TEST_GLOBALS%% | 32 %%TEST_GLOBALS%% |
33 | 33 |
34 daemon off; | 34 daemon off; |
67 set $reply OK; | 67 set $reply OK; |
68 } | 68 } |
69 | 69 |
70 set $userpass "$http_auth_user:$http_auth_salt:$http_auth_pass"; | 70 set $userpass "$http_auth_user:$http_auth_salt:$http_auth_pass"; |
71 if ($userpass ~ '^test@example.com:<.*@.*>:0{32}$') { | 71 if ($userpass ~ '^test@example.com:<.*@.*>:0{32}$') { |
72 set $reply OK; | |
73 set $passw secret; | |
74 } | |
75 | |
76 set $userpass "$http_auth_method:$http_auth_user:$http_auth_pass"; | |
77 if ($userpass ~ '^external:test@example.com:$') { | |
72 set $reply OK; | 78 set $reply OK; |
73 set $passw secret; | 79 set $passw secret; |
74 } | 80 } |
75 | 81 |
76 add_header Auth-Status $reply; | 82 add_header Auth-Status $reply; |
140 $s->check(qr/\+ /, 'auth cram-md5 challenge'); | 146 $s->check(qr/\+ /, 'auth cram-md5 challenge'); |
141 | 147 |
142 $s->send(encode_base64('test@example.com ' . ('0' x 32), '')); | 148 $s->send(encode_base64('test@example.com ' . ('0' x 32), '')); |
143 $s->ok('auth cram-md5'); | 149 $s->ok('auth cram-md5'); |
144 | 150 |
151 TODO: { | |
152 local $TODO = 'not yet' unless $t->has_version('1.11.6'); | |
153 | |
154 # auth external | |
155 | |
156 $s = Test::Nginx::IMAP->new(); | |
157 $s->read(); | |
158 | |
159 $s->send('1 AUTHENTICATE EXTERNAL'); | |
160 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth external challenge'); | |
161 | |
162 $s->send(encode_base64('test@example.com', '')); | |
163 $s->ok('auth external'); | |
164 | |
165 # auth external with username | |
166 | |
167 $s = Test::Nginx::IMAP->new(); | |
168 $s->read(); | |
169 | |
170 $s->send('1 AUTHENTICATE EXTERNAL ' . encode_base64('test@example.com', '')); | |
171 $s->ok('auth external with username'); | |
172 | |
173 } | |
174 | |
145 ############################################################################### | 175 ############################################################################### |