Skip to content

Commit 0e52036

Browse files
committed
Tests: added IMAP LOGIN test with untagged CAPABILITY.
1 parent 871e8fb commit 0e52036

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/Test/Nginx/IMAP.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ sub imap_test_daemon {
166166
print $client '+ ' . CRLF;
167167
$client->sysread(my $buf, $1);
168168
Test::Nginx::log_core('||', $buf);
169+
$_ .= $buf;
169170
$buf = <$client>;
170171
Test::Nginx::log_core('||', $buf);
171172
$_ .= $buf;
@@ -179,6 +180,8 @@ sub imap_test_daemon {
179180
if (/^logout/i) {
180181
print $client $tag . ' OK logout ok' . CRLF;
181182
} elsif (/^login /i) {
183+
print $client "* CAPABILITY IMAP4rev1" . CRLF
184+
if /capability/;
182185
print $client $tag . ' OK login ok' . CRLF;
183186
} else {
184187
print $client $tag . ' ERR unknown command' . CRLF;

mail_imap.t

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ events {
3838
}
3939
4040
mail {
41-
proxy_pass_error_message on;
41+
proxy_pass_error_message off;
4242
proxy_timeout 15s;
4343
auth_http http://127.0.0.1:8080/mail/auth;
4444
@@ -67,6 +67,9 @@ http {
6767
if ($userpass = 'te\\"[email protected]:se\\"cret') {
6868
set $reply OK;
6969
}
70+
if ($userpass = '[email protected]:secret') {
71+
set $reply OK;
72+
}
7073
7174
set $userpass "$http_auth_user:$http_auth_salt:$http_auth_pass";
7275
if ($userpass ~ '^[email protected]:<.*@.*>:0{32}$') {
@@ -93,7 +96,7 @@ http {
9396
EOF
9497

9598
$t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon);
96-
$t->run()->plan(29);
99+
$t->run()->plan(31);
97100

98101
$t->waitforsocket('127.0.0.1:' . port(8144));
99102

@@ -113,6 +116,20 @@ $s->check(qr/^a02 NO/, 'login with bad password');
113116
$s->send('a03 LOGIN [email protected] secret');
114117
$s->ok('login');
115118

119+
# login with untagged capability
120+
121+
TODO: {
122+
local $TODO = 'not yet' unless $t->has_version('1.27.3');
123+
124+
$s = Test::Nginx::IMAP->new();
125+
$s->read();
126+
127+
$s->send('a04 LOGIN [email protected] secret');
128+
$s->check(qr/^\* CAPABILITY /, 'untagged capability');
129+
$s->ok('login after capability');
130+
131+
}
132+
116133
# auth
117134

118135
$s = Test::Nginx::IMAP->new();

0 commit comments

Comments
 (0)