Mercurial > hg > nginx-tests
annotate mail_proxy_smtp_auth.t @ 1677:f13ead27f89c
Tests: improved stop() to send TERM after QUIT.
It is possible that graceful stop as initiated by SIGQUIT will take
very long time, such as when waiting for proxy_timeout in mail proxy
(defaults to 24h). To make sure in such cases nginx is stopped after
some reasonable time, we now send SIGTERM after waiting for 90 seconds.
Note that win32 version previously used "-s stop", which is equivalent
to SIGTERM rather than SIGQUIT. This seems accidental error during
introduction of initial win32 support in tests (ce2e23daa1da), so
it is changed to follow the same logic.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 May 2021 04:32:55 +0300 |
parents | 4e0644119341 |
children | 74986ebee2fd |
rev | line source |
---|---|
1599
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for nginx mail proxy module, the proxy_smtp_auth directive. |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use MIME::Base64; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx::SMTP; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 local $SIG{PIPE} = 'IGNORE'; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/) |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 ->write_file_expand('nginx.conf', <<'EOF'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 events { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 mail { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 proxy_pass_error_message on; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 proxy_smtp_auth on; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 auth_http http://127.0.0.1:8080/mail/auth; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 smtp_auth login plain external; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 listen 127.0.0.1:8025; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 protocol smtp; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 server { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 listen 127.0.0.1:8027; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 protocol smtp; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 xclient off; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 http { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 %%TEST_GLOBALS_HTTP%% |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 server { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 listen 127.0.0.1:8080; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 server_name localhost; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 location = /mail/auth { |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 add_header Auth-Status OK; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 add_header Auth-Server 127.0.0.1; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 add_header Auth-Port %%PORT_8026%%; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 add_header Auth-Wait 1; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 return 204; |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 EOF |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $t->try_run('no proxy_smtp_auth')->plan(7); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $t->waitforsocket('127.0.0.1:' . port(8026)); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 ############################################################################### |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 # The following combinations may be sent to backend with proxy_smtp_auth on: |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 # |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 # ehlo, xclient, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 # ehlo, xclient, helo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 # ehlo, xclient, ehlo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 # helo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 # ehlo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 # |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 # Test them in order. |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 # ehlo, xclient, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 my $s = Test::Nginx::SMTP->new(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 $s->authok('ehlo, xclient, auth'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 # ehlo, xclient, helo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $s = Test::Nginx::SMTP->new(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $s->send('HELO example.com'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 $s->authok('ehlo, xclient, helo, auth'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 # ehlo, xclient, ehlo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 $s = Test::Nginx::SMTP->new(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 $s->send('EHLO example.com'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 $s->authok('ehlo, xclient, ehlo, auth'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 # helo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8027)); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 $s->authok('helo, auth'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 # ehlo, auth |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 $s = Test::Nginx::SMTP->new(PeerAddr => '127.0.0.1:' . port(8027)); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 $s->send('EHLO example.com'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 $s->authok('ehlo, auth'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 # Try auth external |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 $s = Test::Nginx::SMTP->new(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 $s->send('EHLO example.com'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 $s->read(); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 $s->send('AUTH EXTERNAL'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 $s->check(qr/^334 VXNlcm5hbWU6/, 'auth external challenge'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $s->send(encode_base64('test@example.com', '')); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 $s->check(qr/^4.. /, 'auth external no password'); |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
4e0644119341
Tests: proxy_smtp_auth directive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 ############################################################################### |