mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 09:08:49 -05:00
test677: IMAP CONNECT_ONLY, custom command and then exit
Adjusted ftpserver.pl to add support for the IMAP IDLE command Adjusted test 660 to sync with the fix
This commit is contained in:
parent
9accc48850
commit
a5ab72d5ed
@ -90,7 +90,7 @@ test635 test636 test637 test638 test639 test640 test641 test642 \
|
||||
test643 test645 test646 test647 test648 test649 test650 test651 \
|
||||
test652 test653 test654 test655 test656 test658 test659 test660 test661 \
|
||||
test662 test663 test664 test665 test666 test667 test668 test669 \
|
||||
test670 test671 test672 test673 test674 test675 test676 test678 \
|
||||
test670 test671 test672 test673 test674 test675 test676 test677 test678 \
|
||||
\
|
||||
test700 test701 test702 test703 test704 test705 test706 test707 test708 \
|
||||
test709 test710 test711 test712 test713 test714 test715 test716 test717 \
|
||||
|
@ -29,7 +29,6 @@ imap://%HOSTIP:%IMAPPORT/%TESTNUMBER
|
||||
<verify>
|
||||
<protocol>
|
||||
A001 CAPABILITY
|
||||
A002 LOGOUT
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
|
43
tests/data/test677
Normal file
43
tests/data/test677
Normal file
@ -0,0 +1,43 @@
|
||||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
IMAP
|
||||
CONNECT_ONLY
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
imap
|
||||
</server>
|
||||
<name>
|
||||
IMAP with CONNECT_ONLY, custom command then exit
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
imap://%HOSTIP:%IMAPPORT/677
|
||||
</command>
|
||||
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
A001 CAPABILITY
|
||||
A1 IDLE
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
@ -643,6 +643,7 @@ sub protocolsetup {
|
||||
'STATUS' => \&STATUS_imap,
|
||||
'STORE' => \&STORE_imap,
|
||||
'UID' => \&UID_imap,
|
||||
'IDLE' => \&IDLE_imap,
|
||||
);
|
||||
%displaytext = (
|
||||
'welcome' => join("",
|
||||
@ -1587,6 +1588,13 @@ sub COPY_imap {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub IDLE_imap {
|
||||
logmsg "IDLE received\n";
|
||||
|
||||
sendcontrol "+ entering idle mode\r\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub UID_imap {
|
||||
my ($args) = @_;
|
||||
my ($command) = split(/ /, $args, 1);
|
||||
|
@ -48,7 +48,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
|
||||
lib599 \
|
||||
lib643 lib645 lib650 lib651 lib652 lib653 lib654 lib655 lib658 \
|
||||
lib659 lib661 lib666 lib667 lib668 \
|
||||
lib670 lib671 lib672 lib673 lib674 lib676 lib678 \
|
||||
lib670 lib671 lib672 lib673 lib674 lib676 lib677 lib678 \
|
||||
lib1156 \
|
||||
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
|
||||
lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \
|
||||
@ -406,6 +406,10 @@ lib676_SOURCES = lib676.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib676_LDADD = $(TESTUTIL_LIBS)
|
||||
lib676_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib677_SOURCES = lib677.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
|
||||
lib677_LDADD = $(TESTUTIL_LIBS)
|
||||
lib677_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib678_SOURCES = lib678.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
|
||||
lib678_LDADD = $(TESTUTIL_LIBS)
|
||||
lib678_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
117
tests/libtest/lib677.c
Normal file
117
tests/libtest/lib677.c
Normal file
@ -0,0 +1,117 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static const char cmd[] = "A1 IDLE\r\n";
|
||||
static char buf[1024];
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLM *mcurl;
|
||||
CURL *curl;
|
||||
int mrun;
|
||||
curl_socket_t sock = CURL_SOCKET_BAD;
|
||||
time_t start = time(NULL);
|
||||
int state = 0;
|
||||
ssize_t pos = 0;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
mcurl = curl_multi_init();
|
||||
if(!mcurl)
|
||||
return 1;
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
goto fail;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
|
||||
curl_multi_add_handle(mcurl, curl);
|
||||
|
||||
while(time(NULL) - start < 5) {
|
||||
struct curl_waitfd waitfd;
|
||||
|
||||
curl_multi_perform(mcurl, &mrun);
|
||||
for(;;) {
|
||||
int i;
|
||||
struct CURLMsg *m = curl_multi_info_read(mcurl, &i);
|
||||
|
||||
if(!m)
|
||||
break;
|
||||
if(m->msg == CURLMSG_DONE && m->easy_handle == curl) {
|
||||
curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sock);
|
||||
if(sock == CURL_SOCKET_BAD)
|
||||
return 3;
|
||||
printf("Connected fine, extracted socket. Moving on\n");
|
||||
}
|
||||
}
|
||||
|
||||
if(sock != CURL_SOCKET_BAD) {
|
||||
waitfd.events = state ? CURL_WAIT_POLLIN : CURL_WAIT_POLLOUT;
|
||||
waitfd.revents = 0;
|
||||
curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sock);
|
||||
waitfd.fd = sock;
|
||||
}
|
||||
curl_multi_wait(mcurl, &waitfd, sock == CURL_SOCKET_BAD ? 0 : 1, 500,
|
||||
&mrun);
|
||||
if((sock != CURL_SOCKET_BAD) && (waitfd.revents & waitfd.events)) {
|
||||
size_t len = 0;
|
||||
|
||||
if(!state) {
|
||||
curl_easy_send(curl, cmd + pos, sizeof(cmd) - 1 - pos, &len);
|
||||
if(len > 0)
|
||||
pos += len;
|
||||
else
|
||||
pos = 0;
|
||||
if(pos == sizeof(cmd) - 1) {
|
||||
state++;
|
||||
pos = 0;
|
||||
}
|
||||
}
|
||||
else if(pos < (ssize_t)sizeof(buf)) {
|
||||
curl_easy_recv(curl, buf + pos, sizeof(buf) - pos, &len);
|
||||
if(len > 0)
|
||||
pos += len;
|
||||
}
|
||||
if(len <= 0)
|
||||
sock = CURL_SOCKET_BAD;
|
||||
}
|
||||
}
|
||||
|
||||
if(state) {
|
||||
fwrite(buf, pos, 1, stdout);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
curl_multi_remove_handle(mcurl, curl);
|
||||
fail:
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(mcurl);
|
||||
|
||||
curl_global_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user