@@ -12,6 +12,7 @@ use strict;
12
12
use Test::More;
13
13
14
14
use MIME::Base64;
15
+ use Socket qw/ CRLF / ;
15
16
16
17
BEGIN { use FindBin; chdir ($FindBin::Bin ); }
17
18
@@ -60,7 +61,10 @@ http {
60
61
set $passw "";
61
62
62
63
set $userpass "$http_auth_user:$http_auth_pass";
63
- if ($userpass ~ '^[email protected] :secret$') {
64
+ if ($userpass = '[email protected] :secret') {
65
+ set $reply OK;
66
+ }
67
+ if ($userpass = 'te\\"[email protected] :se\\"cret') {
64
68
set $reply OK;
65
69
}
66
70
71
75
}
72
76
73
77
set $userpass "$http_auth_method:$http_auth_user:$http_auth_pass";
74
- if ($userpass ~ '^ external:[email protected] :$ ') {
78
+ if ($userpass = ' external:[email protected] :') {
75
79
set $reply OK;
76
80
set $passw secret;
77
81
}
@@ -89,16 +93,30 @@ http {
89
93
EOF
90
94
91
95
$t -> run_daemon(\&Test::Nginx::IMAP::imap_test_daemon);
92
- $t -> run()-> plan(14 );
96
+ $t -> run()-> plan(23 );
93
97
94
98
$t -> waitforsocket(' 127.0.0.1:' . port(8144));
95
99
96
100
# ##############################################################################
97
101
102
+ # login
103
+
98
104
my $s = Test::Nginx::IMAP-> new();
99
105
$s -> ok(' greeting' );
100
106
101
- # bad auth
107
+ $s -> send (' a01 LOGIN' );
108
+ $s -> check(qr / ^a01 BAD/ , ' login without arguments' );
109
+
110
+ $s -> send (
' a02 LOGIN [email protected] bad' );
111
+ $s -> check(qr / ^a02 NO/ , ' login with bad password' );
112
+
113
+ $s -> send (
' a03 LOGIN [email protected] secret' );
114
+ $s -> ok(' login' );
115
+
116
+ # auth
117
+
118
+ $s = Test::Nginx::IMAP-> new();
119
+ $s -> read ();
102
120
103
121
$s -> send (' 1 AUTHENTICATE' );
104
122
$s -> check(qr / ^\S + BAD/ , ' auth without arguments' );
@@ -166,4 +184,51 @@ $s->read();
166
184
$s -> send (
' 1 AUTHENTICATE EXTERNAL ' . encode_base64(
' [email protected] ' ,
' ' ));
167
185
$s -> ok(' auth external with username' );
168
186
187
+ # quoted strings
188
+
189
+ $s = Test::Nginx::IMAP-> new();
190
+ $s -> read ();
191
+
192
+ $s -> send (
' a01 LOGIN "te\\\\ \"[email protected] " "se\\\\ \"cret"' );
193
+ $s -> ok(' quoted strings' );
194
+
195
+ # literals
196
+
197
+ $s = Test::Nginx::IMAP-> new();
198
+ $s -> read ();
199
+
200
+ $s -> send (' a01 LOGIN {18}' );
201
+ $s -> check(qr /\+ / , ' login username literal continue' );
202
+
203
+ $s -> send (
' te\"[email protected] ' .
' {8}' );
204
+ $s -> check(qr /\+ / , ' login password literal continue' );
205
+
206
+ $s -> send (' se\"cret' );
207
+ $s -> ok(' login literals' );
208
+
209
+ # non-synchronizing literals
210
+
211
+ $s = Test::Nginx::IMAP-> new();
212
+ $s -> read ();
213
+
214
+ $s -> send (' a01 LOGIN {18+}' . CRLF
215
+ .
' te\"[email protected] ' .
' {8+}' . CRLF
216
+ . ' se\"cret' );
217
+ $s -> ok(' login non-sync literals' );
218
+
219
+ # backslash in quotes and literals
220
+
221
+ $s = Test::Nginx::IMAP-> new();
222
+ $s -> read ();
223
+
224
+ $s -> send (' a01 LOGIN {18+}' . CRLF
225
+ .
' te\"[email protected] ' .
' "se\\\\ \"cret"' );
226
+
227
+ TODO: {
228
+ local $TODO = ' not yet' unless $t -> has_version(' 1.21.0' );
229
+
230
+ $s -> ok(' backslash in literal' );
231
+
232
+ }
233
+
169
234
# ##############################################################################
0 commit comments